/* Shared base + components used by every page. Sizes come from design/mockups. */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }

img { display: block; }

button, input, select { font: inherit; color: inherit; }

:where(button, a, select, input, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Titles ---------- */
.title-pink {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--title-color);
  text-shadow: 2px 2px 0 var(--pink-shadow);
  line-height: 1.15;
}
.title-mauve {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 800;
  color: var(--queue-title-color);
  text-shadow: 2px 2px 0 var(--mauve-shadow);
  line-height: 1.1;
}
.title-plain {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
}

/* ---------- Buttons: ink outline, hard ink shadow ---------- */
.btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: var(--radius-btn);
  padding: 10px 16px;
  min-height: 44px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 80ms ease, box-shadow 80ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { color: var(--ink); transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 0 3px 0 var(--ink); }
.btn-sm { font-size: 14px; padding: 6px 12px; min-height: 36px; }

.link-btn {
  font-family: var(--font-ui);
  font-size: 15px;
  background: none;
  border: none;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 2px;
  min-height: 36px;
}
.link-btn[disabled] { opacity: 0.45; cursor: default; text-decoration: none; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 15px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
  max-width: 100%;
}
/* A long name inside a pill ends in "…" (the full name is in its title). */
.pill-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
button.pill { cursor: pointer; min-height: 40px; }
button.pill[aria-pressed='true'] { font-weight: 600; background: var(--mauve); box-shadow: 0 3px 0 var(--ink); }

.badge {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  background: var(--mauve);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
  line-height: 1.4;
}

/* ---------- Form controls ---------- */
.field {
  font-family: var(--font-ui);
  font-size: 16px;
  padding: 8px 10px;
  border: var(--line) solid var(--ink);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
}
.label {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 15px;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
}
.switch input { width: 22px; height: 22px; accent-color: var(--green); margin: 0; }

/* ---------- Scalloped card: the mood board's signature frame ----------
   Circles tiled along the four edges in ::before, a white ::after on top,
   and a drop-shadow that gives the colored backing (set --sc). `round` stretches the tiles a
   little so a whole number fits each edge; the dots are ellipses so they stretch with them
   (circles left gaps along the sides of short cards). */
.sc {
  --sc: var(--aqua);
  --sc-size: 18px;
  --sc-line: 2.5px;
  --sc-out: -9px;
  --sc-drop: 7px;
  position: relative;
  isolation: isolate;
}
.sc::before {
  --dot: radial-gradient(closest-side, #fff 0 calc(100% - var(--sc-line)), var(--ink) calc(100% - var(--sc-line)) 100%, transparent 100%);
  content: '';
  position: absolute;
  inset: var(--sc-out);
  z-index: -1;
  background-image: var(--dot), var(--dot), var(--dot), var(--dot);
  background-position: left top, left bottom, left top, right top;
  background-size: var(--sc-size) var(--sc-size);
  background-repeat: round no-repeat, round no-repeat, no-repeat round, no-repeat round;
  filter: drop-shadow(0 var(--sc-drop) 0 var(--sc));
}
.sc::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #fff;
}
.sc-lg { --sc-size: 22px; --sc-line: 3px; --sc-out: -11px; --sc-drop: 9px; }

/* Settings › Theme › Card frames. Same box and colored backing, simpler edge. */
:root[data-frame="rounded"] .sc::before {
  background: #fff;
  border: var(--sc-line) solid var(--ink);
  border-radius: calc(var(--radius-card) + 6px);
  inset: -6px;
}
:root[data-frame="rounded"] .sc::after { border-radius: var(--radius-card); }
:root[data-frame="plain"] .sc::before {
  background: #fff;
  border: var(--sc-line) solid var(--ink);
  border-radius: calc(var(--radius-btn) + 4px);
  inset: -4px;
  filter: none;
  box-shadow: 0 4px 0 var(--ink);
}
:root[data-frame="plain"] .sc::after { border-radius: var(--radius-btn); }

/* ---------- Queue numerals: ink stroke drawn behind the fill ---------- */
queue-num, .num {
  font-family: var(--font-ui);
  font-weight: 700;
  -webkit-text-stroke: var(--num-stroke, 2.5px) var(--ink);
  paint-order: stroke fill;
  line-height: 1;
  display: inline-flex;
  justify-content: center;
}
queue-num .d1 { color: var(--d1); } queue-num .d2 { color: var(--d2); }
queue-num .d3 { color: var(--d3); } queue-num .d4 { color: var(--d4); }
queue-num .d5 { color: var(--d5); } queue-num .d6 { color: var(--d6); }
queue-num .d7 { color: var(--d7); } queue-num .d8 { color: var(--d8); }
queue-num .d9 { color: var(--d9); } queue-num .d0 { color: var(--d0); }

/* ---------- Dialogs ---------- */
dialog.modal {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
  max-width: calc(100vw - 32px);
}
dialog.modal::backdrop { background: var(--scrim); }
.modal-card {
  padding: 26px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(460px, calc(100vw - 48px));
}
.modal-card h2 { margin: 0; font-family: var(--font-ui); font-weight: 700; font-size: 24px; overflow-wrap: anywhere; }
.modal-card p { margin: 0; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  font-family: var(--font-ui);
  font-weight: 500;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 10px 16px;
  max-width: min(560px, calc(100vw - 32px));
  text-align: center;
  overflow-wrap: anywhere;
  animation: toast-in 180ms ease-out;
}
.toast.error { background: #ffe1dc; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Confetti burst */
.confetti-sky { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.confetti { position: absolute; left: 50%; top: 40%; width: 0; height: 0; pointer-events: none; }
.confetti i {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px;
  background: var(--c);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: burst 900ms cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

/* Moving between pages: browsers that support it cross-fade from one page to the next instead of
   blanking the screen. The page's own content fades in once its data has loaded (js/pages/shell.js). */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; }
.main, .present-wrap { transition: opacity 180ms ease-out, translate 180ms ease-out; }
:root.page-loading .main, :root.page-loading .present-wrap { opacity: 0; translate: 0 6px; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .confetti { display: none; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
