/* Arte Bebé design tokens — see DESIGN.md. Colors sampled from product photos. */
:root {
  --linen: #f6f1ea;
  --linen-deep: #ede5da;
  --surface: #fffdfa;
  --line: #e6ddd2;

  /* Ink: gray embroidery thread */
  --ink: #4c464d;
  --ink-soft: #8b8288;
  --ink-faint: #b9b0ac;

  /* Accents */
  --rose: #c98a9f;
  --rose-deep: #a8687e;
  --rose-wash: #f7e7ec;
  --gold: #b08a52;

  /* Embroidery hoop wood */
  --wood-light: #e3c49b;
  --wood: #c99c6a;
  --wood-dark: #9c7246;

  --thread-color: #73707c; /* set from app.js */
  --thread-shadow: rgba(60, 45, 40, 0.2);

  --font-ui: ui-sans-serif, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Didot", "Bodoni 72", "Cormorant Garamond", Georgia, serif;
  --font-script: "Edwardian Script", cursive;

  /* A dashed "stitch" line, reused for active states */
  --stitch: repeating-linear-gradient(90deg, var(--rose) 0 7px, transparent 7px 11px);

  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--linen);
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
  /* No double-tap zoom (quick taps on spools or arrows); pinch zoom still works */
  touch-action: manipulation;
}

html,
body {
  height: 100%;
}

/* The app fills the screen and never scrolls as a page, so no rubber-band. */
html {
  overscroll-behavior: none;
}

body {
  margin: 0;
  /* Linen weave */
  background-color: var(--linen);
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 95, 70, 0.025) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120, 95, 70, 0.025) 0 1px, transparent 1px 3px);
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--rose-deep);
  outline-offset: 3px;
}

/* ---------- App shell: one screen, no page scroll on phones ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.top {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 20px 0;
}

.logo {
  width: 64px;
  height: 64px;
  /* The logo has a white background; multiply blends it into the linen. */
  mix-blend-mode: multiply;
}

.tagline {
  margin: -4px 0 0;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.tagline-script {
  font-family: var(--font-script);
  font-size: 22px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--rose-deep);
}

/* ---------- Stage: the name inside an embroidery hoop ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 12px 0;
}

.stage-inner {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
  container-type: size;
}

.hoop {
  position: relative;
  /* Leave room above for the screw */
  width: min(84cqw, 84cqh);
  margin-top: 6cqh;
  aspect-ratio: 1;
  touch-action: pan-y pinch-zoom;
}

/* Outer wooden ring */
.hoop-ring {
  width: 100%;
  height: 100%;
  padding: 4.2%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 45%),
    conic-gradient(from 200deg, var(--wood-light), var(--wood), var(--wood-dark), var(--wood), var(--wood-light));
  box-shadow:
    0 30px 50px -28px rgba(80, 55, 30, 0.55),
    0 8px 18px -10px rgba(80, 55, 30, 0.35),
    inset 0 0 0 1px rgba(90, 60, 30, 0.25);
}

/* Fabric stretched inside, with the inner ring's shadow */
.hoop-fabric {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 3px rgba(156, 114, 70, 0.55),
    inset 0 6px 14px rgba(60, 40, 20, 0.28),
    inset 0 -20px 40px -20px rgba(60, 40, 20, 0.18);
  transition: background-color 0.35s;
}

/* Brass tightening screw on top of the hoop */
.hoop-screw {
  position: absolute;
  top: -3.5%;
  left: 50%;
  z-index: 1;
  width: 9%;
  height: 7.5%;
  transform: translateX(-50%);
  border-radius: 4px;
  background: linear-gradient(90deg, #a98a52, #e7d3a2 45%, #a98a52);
  box-shadow: 0 2px 4px rgba(60, 40, 20, 0.35);
}

.hoop-screw::before {
  content: "";
  position: absolute;
  top: -55%;
  left: 50%;
  width: 55%;
  height: 70%;
  transform: translateX(-50%);
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(90deg, #a98a52, #f0e0b4 45%, #a98a52);
}

.sample {
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--thread-color);
  transition: color 0.3s;
}

.hero-sample {
  /* Raised satin-stitch look */
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45),
    0 2px 3px var(--thread-shadow);
}

.sample.placeholder {
  opacity: 0.45;
}

.hero-sample.stitch {
  animation: stitch 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes stitch {
  from {
    opacity: 0;
    transform: scale(0.94);
    /* Negative insets leave room for script swashes, which can reach far
       outside the text box (tall capitals, long tails); too tight and they
       get clipped while the name appears, then pop in at the end. */
    clip-path: inset(-150% 100% -150% -60%);
  }
  to {
    opacity: 1;
    transform: none;
    clip-path: inset(-150% -60% -150% -60%);
  }
}

.nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 250, 0.9);
  box-shadow: 0 6px 16px -8px rgba(60, 45, 40, 0.4);
  cursor: pointer;
  transition: transform 0.15s;
}

.nav:active {
  transform: scale(0.92);
}

.nav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-prev {
  left: 2px;
}

.nav-next {
  right: 2px;
}

.stage-caption {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Intro: the name, on its own screen ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 28px) 24px 24px;
  background: inherit;
  text-align: center;
}

body.is-intro .intro {
  display: flex;
}

body.is-intro .app {
  visibility: hidden;
}

.intro-logo {
  width: 84px;
  height: 84px;
  mix-blend-mode: multiply;
}

.intro-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.intro-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.15;
}

/* Live preview of the name in the house script while typing */
.intro-preview {
  min-height: 1.3em;
  max-width: 100%;
  margin: 6px 0 0;
  overflow: hidden;
  font-family: "Athena of the Ocean", cursive;
  font-size: clamp(44px, 14vw, 72px);
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--thread-color);
}

.intro-preview.placeholder {
  opacity: 0.3;
}

.intro-field {
  width: min(420px, 100%);
}

.intro-input {
  width: 100%;
  padding: 16px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 12px 28px -20px rgba(80, 55, 30, 0.55);
  font-family: var(--font-display);
  font-size: 22px; /* ≥16px so iOS doesn't zoom in */
  text-align: center;
  color: var(--ink);
  outline: none;
}

.intro-input:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 4px rgba(201, 138, 159, 0.15);
}

.intro-input::placeholder {
  color: var(--ink-faint);
}

.btn.intro-go {
  flex: none;
  width: min(420px, 100%);
  margin-top: 4px;
}

.btn.intro-go:disabled {
  opacity: 0.35;
  cursor: default;
}

.edit-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
}

.edit-name svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--rose-deep);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

/* ---------- Controls: tabs, one panel at a time ---------- */
.controls {
  padding: 12px 16px 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  border: 0;
  background: none;
  cursor: pointer;
}

.tab-label {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink-soft);
  transition: color 0.2s;
}

.tab-value {
  max-width: 100%;
  overflow: hidden;
  font-size: 10px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink-faint);
}

.tab[aria-selected="true"] .tab-label {
  color: var(--ink);
}

.tab[aria-selected="true"] .tab-value {
  color: var(--rose-deep);
}

/* Active tab underlined with a stitch */
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 18%;
  right: 18%;
  height: 2px;
  background: var(--stitch);
}

.panels {
  height: 138px;
  margin-top: 12px;
}

.panel {
  height: 100%;
}

/* Horizontal rails: swipe through options with snap */
.rail {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  height: 100%;
  margin: 0 -16px;
  padding: 4px 16px 10px;
  overflow-x: auto;
  /* Sideways only: a vertical swipe on the rail must not wiggle it or the page */
  overflow-y: hidden;
  overscroll-behavior: contain;
  touch-action: pan-x pinch-zoom;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail > * {
  scroll-snap-align: center;
  flex: none;
}

/* Font cards: the name written in each font */
.font-card {
  position: relative;
  width: 150px;
  height: 112px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}

.font-card-box {
  position: absolute;
  inset: 22px 10px 10px;
  display: grid;
  place-items: center;
}

.font-card-num {
  position: absolute;
  top: 8px;
  left: 12px;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink-faint);
}

.font-card[aria-checked="true"] {
  border-color: transparent;
  background: var(--rose-wash);
  box-shadow: 0 10px 22px -16px rgba(168, 104, 126, 0.8);
}

/* Stitched outline on the chosen option */
.font-card[aria-checked="true"]::after,
.scrap[aria-checked="true"] .scrap-cloth::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1.5px dashed var(--rose);
  border-radius: 12px;
  pointer-events: none;
}

.font-card[aria-checked="true"] .font-card-num {
  color: var(--rose-deep);
}

/* Thread spools */
.rail-threads {
  gap: 18px;
}

.spool-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spool-group-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-soft);
}

.spool-row {
  display: flex;
  gap: 6px;
}

.spool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 44px;
  padding: 4px 0 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* Wooden flanges top and bottom, thread wound between */
.spool-body {
  position: relative;
  width: 34px;
  height: 64px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.1) 0 1px, rgba(0, 0, 0, 0.06) 1px 2px, transparent 2px 3px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(255, 255, 255, 0.28) 40%, rgba(0, 0, 0, 0.2)),
    var(--thread);
  box-shadow: 0 6px 10px -6px rgba(40, 25, 15, 0.5);
  transition: transform 0.2s;
}

.spool-body::before,
.spool-body::after {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  height: 7px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--wood-dark), var(--wood-light) 45%, var(--wood));
}

.spool-body::before {
  top: -4px;
}

.spool-body::after {
  bottom: -4px;
}

.spool-num {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.spool[aria-checked="true"] .spool-body {
  transform: translateY(-4px);
}

.spool[aria-checked="true"] .spool-num {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
}

/* Fabric scraps */
.fabric {
  background-color: var(--fabric-color, #fff);
}

.fabric[data-kind="minky"] {
  /* Raised minky bubbles: a highlight over a soft shadow */
  background-image:
    radial-gradient(circle at 45% 40%, rgba(255, 255, 255, 0.6) 0 2px, transparent 3.5px),
    radial-gradient(circle at 50% 55%, rgba(80, 60, 50, 0.11) 0 4px, transparent 5.5px);
  background-size: 22px 22px;
}

.fabric[data-kind="stripes"] {
  background-image: repeating-linear-gradient(90deg, var(--fabric-accent) 0 2px, transparent 2px 6px);
}

.fabric[data-kind="print"] {
  background-image: var(--fabric-image);
  background-size: cover;
  background-position: center;
}

.scrap-row {
  display: flex;
  gap: 4px;
}

.scrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 84px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.scrap-cloth {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(95, 80, 70, 0.12), 0 8px 14px -10px rgba(60, 45, 40, 0.5);
  transition: transform 0.2s;
}

.scrap-cloth[data-kind="print"] {
  background-size: cover;
}

.scrap-cloth[data-kind="minky"] {
  background-size: 13px 13px;
}

.scrap-cloth[data-kind="stripes"] {
  background-image: repeating-linear-gradient(90deg, var(--fabric-accent) 0 1.5px, transparent 1.5px 4.5px);
}

.scrap[aria-checked="true"] .scrap-cloth {
  transform: translateY(-3px);
}

.scrap-name {
  font-size: 10.5px;
  line-height: 1.2;
  text-align: center;
  color: var(--ink-soft);
}

.scrap[aria-checked="true"] .scrap-name {
  font-weight: 600;
  color: var(--ink);
}

/* Summary */
.panel-done {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.summary-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin: 2px 0 0;
}

.summary-list div {
  min-width: 0;
}

.summary-list dt {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.summary-list dd {
  margin: 1px 0 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.summary-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: grid;
  place-items: center;
  padding: 13px 18px;
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  flex: 1;
  border: 0;
  background: var(--ink);
  color: #fff;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

/* ---------- Desktop: hoop on the left, controls on the right ---------- */
@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 48px;
    max-width: 1320px;
    padding: 24px 40px;
  }

  .top {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 14px;
    padding: 0 0 8px;
  }

  .logo {
    width: 72px;
    height: 72px;
  }

  .tagline {
    margin: 0;
  }

  .stage {
    padding: 0;
  }

  .nav {
    width: 48px;
    height: 48px;
    margin-top: -24px;
  }

  .stage-caption {
    margin-top: 16px;
  }

  .controls {
    display: flex;
    flex-direction: column;
    align-self: center;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: rgba(255, 253, 250, 0.7);
    backdrop-filter: blur(6px);
  }

  .panels {
    height: 440px;
  }

  /* On desktop the rails wrap into grids instead of scrolling sideways */
  .rail {
    flex-wrap: wrap;
    align-content: flex-start;
    margin: 0;
    padding: 4px 0;
    overflow: auto;
    touch-action: auto;
  }

  .rail-fonts {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .font-card {
    width: auto;
    height: 92px;
  }

  .rail-threads {
    gap: 12px 18px;
  }

  .rail-fabrics {
    gap: 14px;
  }

  .rail-fabrics .spool-group {
    width: 100%;
  }

  .scrap-row {
    flex-wrap: wrap;
    gap: 12px 6px;
  }

  .scrap {
    width: auto;
  }

  .panel-done {
    justify-content: flex-start;
    gap: 28px;
  }

  .summary-list {
    gap: 18px;
  }

  .summary-list dd {
    font-size: 19px;
    white-space: normal;
  }
}
