/* ==========================================================================
   Apps Rack — base stylesheet
   ========================================================================== */

:root {
  --ink: #1c1a29;
  --ink-soft: #4b4860;
  --muted: #77738a;
  --paper: #faf8f4;
  --surface: #ffffff;
  --surface-alt: #f2eee6;
  --line: #e6e1d6;

  --primary: #4338ca;
  --primary-ink: #ffffff;
  --primary-soft: #eef0ff;
  --accent: #f59e0b;

  --wood: #b98455;
  --wood-dark: #8a5a33;
  --wood-light: #d8a878;

  --success: #15803d;
  --danger: #b91c1c;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 26, 41, .06), 0 1px 3px rgba(28, 26, 41, .08);
  --shadow: 0 10px 30px -12px rgba(28, 26, 41, .25);
  --container: 1180px;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f1eff8;
    --ink-soft: #c9c5d8;
    --muted: #9893ad;
    --paper: #14131c;
    --surface: #1c1b27;
    --surface-alt: #232231;
    --line: #2f2d40;
    --primary: #818cf8;
    --primary-ink: #14131c;
    --primary-soft: #25264a;
    --wood: #8a5a33;
    --wood-dark: #5e3b1f;
    --wood-light: #a8723f;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --ink: #f1eff8;
  --ink-soft: #c9c5d8;
  --muted: #9893ad;
  --paper: #14131c;
  --surface: #1c1b27;
  --surface-alt: #232231;
  --line: #2f2d40;
  --primary: #818cf8;
  --primary-ink: #14131c;
  --primary-soft: #25264a;
  --wood: #8a5a33;
  --wood-dark: #5e3b1f;
  --wood-light: #a8723f;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; color: var(--ink-soft); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 32px; } }

.section { padding: 72px 0; }
.section--alt { background: var(--surface-alt); }
.section__head { max-width: 640px; margin: 0 auto 48px; text-align: center; }
.eyebrow {
  display: inline-block;
  font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary); margin-bottom: .75em;
}
.lead { font-size: 1.15rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .8em 1.4em; border-radius: 999px; border: 1.5px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none !important; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-sm); }
.btn--primary:hover { box-shadow: var(--shadow); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface); }
.btn--sm { padding: .55em 1em; font-size: .88rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 24px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.nav__links { display: flex; gap: 4px; margin-left: auto; list-style: none; padding: 0; margin-top: 0; margin-bottom: 0; }
.nav__links a {
  display: block; padding: .5em .85em; border-radius: 999px;
  color: var(--ink-soft); font-weight: 500; font-size: .95rem;
}
.nav__links a:hover { background: var(--surface-alt); color: var(--ink); text-decoration: none; }
.nav__links a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.nav__actions { display: flex; gap: 8px; align-items: center; }
.theme-toggle, .nav__toggle {
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-grid; place-items: center; font-size: 1.05rem;
}
.nav__toggle { display: none; }

@media (max-width: 880px) {
  .nav__toggle { display: inline-grid; }
  .nav__links {
    display: none; position: absolute; top: 68px; left: 0; right: 0;
    flex-direction: column; padding: 12px 16px 20px;
    background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  }
  .nav__links.is-open { display: flex; }
  .nav__links a { padding: .8em 1em; }
  .nav__actions { margin-left: auto; }
  .nav__actions .btn--ghost { display: none; }
}
@media (max-width: 420px) {
  .nav__actions .btn--primary { padding: .55em .9em; }
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; overflow: hidden; }
.hero__grid { display: grid; gap: 48px; align-items: center; }
@media (min-width: 960px) { .hero__grid { grid-template-columns: 1.05fr 1fr; } }
.hero h1 em { font-style: italic; color: var(--primary); }
.hero__ctas { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 24px; }
.hero__trust { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .9rem; color: var(--muted); padding: 0; margin: 0; list-style: none; }
.hero__trust li::before { content: "✓ "; color: var(--success); font-weight: 700; }

/* ---------- The Rack (bookshelf) ---------- */
.rack {
  position: relative;
  background: linear-gradient(180deg, var(--wood-dark), var(--wood) 6%, var(--wood) 94%, var(--wood-dark));
  border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
}
.rack__row { position: relative; }
.rack__row + .rack__row { margin-top: 30px; }
.rack__shelf {
  display: flex; align-items: flex-end; gap: 4px;
  min-height: 180px; padding: 24px 14px 0;
  background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.12) 30%, rgba(0,0,0,.18));
  border-radius: 4px 4px 0 0;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
}
.rack__plank {
  height: 14px; margin: 0 -6px; border-radius: 3px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  box-shadow: 0 4px 6px rgba(0,0,0,.25);
}
.rack__label {
  position: absolute; top: 4px; left: 10px; z-index: 3;
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: #fff7ec; background: rgba(0,0,0,.25); padding: 1px 8px; border-radius: 4px;
}

.spine {
  --c: #4f46e5;
  position: relative; flex: 0 0 auto;
  width: 44px; height: var(--h, 140px);
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(90deg, rgba(0,0,0,.22), rgba(255,255,255,.12) 18%, rgba(255,255,255,0) 40%, rgba(0,0,0,.18)),
    var(--c);
  color: #fff; border-radius: 3px 3px 0 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
  transform-origin: bottom center;
  transition: transform .2s ease, box-shadow .2s ease;
  text-decoration: none !important; cursor: pointer;
}
.spine::before, .spine::after {
  /* decorative bands */
  content: ""; position: absolute; left: 6px; right: 6px; height: 3px; background: rgba(255,255,255,.55); border-radius: 2px;
}
.spine::before { top: 12px; }
.spine::after { bottom: 12px; }
.spine__title {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--font-display); font-weight: 600; font-size: .95rem; letter-spacing: .04em;
  white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.spine:hover, .spine:focus-visible { transform: translateY(-14px); box-shadow: 0 10px 18px rgba(0,0,0,.35); z-index: 2; }
.spine--soon { filter: saturate(.35) brightness(.9); }
.spine--soon .spine__title::after { content: " · soon"; font-size: .7rem; opacity: .85; }
.spine--tilt { transform: rotate(-6deg); margin-left: 10px; }
.spine--tilt:hover { transform: rotate(-6deg) translateY(-14px); }

.rack__shelf .spine:first-child { margin-left: auto; }
.rack__shelf .spine:last-child { margin-right: auto; }

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: 20px; }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.feature-card .icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-size: 1.3rem; margin-bottom: 14px;
}
.feature-card p { margin: 0; }

.app-card {
  display: flex; flex-direction: column; gap: 12px;
  color: inherit; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.app-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.app-card__top { display: flex; align-items: center; gap: 12px; }
.app-card h3 { margin: 0; }
.app-card p { margin: 0; flex: 1; font-size: .95rem; }
.app-card__meta { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); padding-top: 12px; border-top: 1px dashed var(--line); }
.app-card__meta strong { color: var(--ink); }

.app-icon {
  --c: #4f46e5;
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--c); color: #fff; font-weight: 800; font-size: 1.1rem;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.app-icon--lg { width: 80px; height: 80px; border-radius: 20px; font-size: 1.8rem; }

.badge {
  display: inline-block; padding: .15em .65em; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--surface-alt); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge--soon { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge--free { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

/* ---------- Steps ---------- */
.steps { counter-reset: step; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); list-style: none; padding: 0; margin: 0; }
.steps li { position: relative; padding: 24px; padding-top: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 20px; left: 24px; width: 32px; height: 32px; border-radius: 999px;
  display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 700;
}
.steps h3 { margin-bottom: .3em; }
.steps p { margin: 0; font-size: .95rem; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; text-align: center; }
.stat__num { font-family: var(--font-display); font-size: 2.4rem; font-weight: 600; color: var(--ink); line-height: 1; }
.stat__label { color: var(--muted); font-size: .9rem; margin-top: 6px; }

/* ---------- CTA band ---------- */
.cta-band {
  background: linear-gradient(135deg, #1e1b4b, #4338ca);
  color: #fff; border-radius: 24px; padding: 48px 32px; text-align: center;
}
.cta-band h2 { color: #fff; }
.cta-band p { color: #c7d2fe; max-width: 560px; margin: 0 auto 24px; }
.cta-band .btn--primary { background: #fff; color: #1e1b4b; }
.cta-band .btn--ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.cta-band .btn--ghost:hover { background: rgba(255,255,255,.1); }

/* ---------- Catalog toolbar ---------- */
.page-head { padding: 56px 0 32px; }
.page-head p { max-width: 640px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 28px; }
.search {
  flex: 1 1 260px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 16px;
}
.search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--ink); padding: .75em 0; outline: none; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: .45em 1em; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: .88rem; font-weight: 500; color: var(--ink-soft); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.view-toggle button { border: 0; background: transparent; font: inherit; font-size: .88rem; padding: .5em 1em; cursor: pointer; color: var(--ink-soft); }
.view-toggle button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- App detail ---------- */
.app-hero { display: grid; gap: 32px; padding: 56px 0 24px; }
@media (min-width: 900px) { .app-hero { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.app-hero__title { display: flex; gap: 20px; align-items: center; margin-bottom: 20px; }
.app-hero__title h1 { margin: 0; font-size: clamp(2rem, 4vw, 2.8rem); }
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--muted); }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.check-list li { padding-left: 28px; position: relative; color: var(--ink-soft); }
.check-list li::before {
  content: "✓"; position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 999px;
  display: grid; place-items: center; font-size: .72rem; font-weight: 800;
  background: var(--primary-soft); color: var(--primary);
}
.buy-box { position: sticky; top: 88px; }
.buy-box .price { font-family: var(--font-display); font-size: 2.4rem; font-weight: 600; color: var(--ink); line-height: 1; }
.buy-box dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 20px 0; font-size: .92rem; }
.buy-box dt { color: var(--muted); }
.buy-box dd { margin: 0; text-align: right; font-weight: 600; }

/* ---------- Pricing ---------- */
.billing-toggle { display: inline-flex; align-items: center; gap: 12px; margin: 0 auto 36px; font-weight: 500; }
.switch { position: relative; width: 48px; height: 26px; border-radius: 999px; background: var(--line); border: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; transition: transform .2s ease; box-shadow: var(--shadow-sm); }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.plans { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: stretch; }
.plan { display: flex; flex-direction: column; }
.plan--featured { border: 2px solid var(--primary); position: relative; }
.plan--featured::before {
  content: "Most popular"; position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: var(--primary-ink); font-size: .75rem; font-weight: 700; padding: 3px 12px; border-radius: 999px;
}
.plan__price { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; color: var(--ink); line-height: 1; margin: 12px 0 4px; }
.plan__price small { font-family: var(--font-sans); font-size: .9rem; font-weight: 500; color: var(--muted); }
.plan .check-list { margin: 20px 0 28px; flex: 1; }

.faq { max-width: 760px; margin: 0 auto; }
.faq details { border-bottom: 1px solid var(--line); padding: 18px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--primary); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 12px 0 0; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7em .9em;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { min-height: 140px; resize: vertical; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field .error { font-size: .82rem; color: var(--danger); margin-top: 4px; display: none; }
.field.has-error .error { display: block; }
.alert { padding: 14px 16px; border-radius: var(--radius-sm); background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* ---------- Get started wizard ---------- */
.wizard { max-width: 860px; margin: 0 auto; }
.progress { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 32px; counter-reset: p; }
.progress li { flex: 1; font-size: .82rem; font-weight: 600; color: var(--muted); }
.progress li::before { content: ""; display: block; height: 6px; border-radius: 999px; background: var(--line); margin-bottom: 8px; }
.progress li.is-done::before, .progress li.is-active::before { background: var(--primary); }
.progress li.is-active { color: var(--ink); }
.wizard__step[hidden] { display: none; }
.wizard__nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }

.pick-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pick {
  position: relative; display: flex; gap: 12px; align-items: center;
  padding: 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.pick input { position: absolute; opacity: 0; }
.pick .app-icon { width: 40px; height: 40px; font-size: .95rem; }
.pick strong { display: block; font-size: .95rem; }
.pick span.muted { font-size: .8rem; }
.pick:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pick:has(input:checked)::after {
  content: "✓"; position: absolute; top: 10px; right: 12px; width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-size: .75rem; font-weight: 800;
}
.pick:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.pick:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface-alt); font-size: .95rem; }

/* ---------- About ---------- */
.split { display: grid; gap: 40px; align-items: center; }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1fr; } }
.quote {
  font-family: var(--font-display); font-size: clamp(1.3rem, 2.5vw, 1.7rem); line-height: 1.4; color: var(--ink);
  border-left: 4px solid var(--accent); padding-left: 20px; margin: 0;
}

/* ---------- Footer ---------- */
.site-footer { margin-top: 72px; border-top: 1px solid var(--line); background: var(--surface); padding: 56px 0 28px; font-size: .92rem; }
.footer__grid { display: grid; gap: 32px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.footer__grid h4 { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.footer__grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer__grid a { color: var(--ink-soft); }
.footer__brand p { max-width: 280px; margin-top: 12px; }
.footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
