/* FlossyPurse Studios — the shared shell.

   The design tokens and the app shell (rail, top bar, tab bar, search
   palette, footer) plus the few pieces every page leans on: the eyebrow,
   buttons and cards. Every studio page links this BEFORE styles.css, and the
   Data app (a separate app served at /data on this domain) links it too, so
   the two look like one site. Class names here are a contract with Data:
   rename one and Data breaks. Page styles stay in styles.css. */

:root {
  /* type */
  --font-display: "Bricolage Grotesque", "Archivo Black", ui-sans-serif, system-ui, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 800;
  --display-tracking: -0.045em;

  --h1: 2.6rem;      /* 390px */
  --h2: 1.75rem;
  --h3: 1.25rem;
  --lead: 1.08rem;
  --body: 1rem;
  --small: 0.9rem;
  --micro: 0.78rem;

  /* colour — surfaces and ink */
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f6f1e7;
  --line: #e7e0d2;
  --line-soft: #efe9dd;
  --rule: #16181d;
  --fg: #16181d;
  --fg-dim: #4a4f58;
  --fg-mute: #666b73;    /* 4.7:1 on --surface-2, the darkest paper */

  /* colour — the five */
  --hero: #ff4d3d;
  --hero-deep: #e0361f;   /* hover / pressed on decorative marks */
  --hero-ink: #c92a14;    /* the only colour allowed to carry small text; white on it is 5.5:1 */
  --hero-ink-deep: #a8220f; /* pressed state for anything filled with --hero-ink */
  --hero-wash: #fff0ed;
  --marigold: #ffb302;
  --teal: #0fa3a3;
  --ultramarine: #2b4fe0;
  --magenta: #e5399a;

  /* semantic */
  --accent: var(--hero);
  --warn: #8a5c00;
  --ok: #0b7d5e;

  /* space */
  --gap: 1rem;
  --section-y: 4.5rem;
  --measure: 34rem;
  --wide: 68rem;
}

@media (min-width: 44em) {
  :root {
    --h1: 3.6rem;
    --h2: 2.15rem;
    --lead: 1.15rem;
    --section-y: 5rem;
  }
}

@media (min-width: 64em) {
  :root {
    --h1: 4.4rem;
    --h2: 2.5rem;
    --lead: 1.2rem;
    --section-y: 5.5rem;
  }
}

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

.wrap {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 1.25rem;
}

@media (min-width: 44em) { .wrap { padding: 0 2rem; } }

/* The eyebrow carries a coral block instead of the old "// " — same job, but it
   reads as a printed marker rather than a code comment. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--micro);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.eyebrow::before {
  content: "";
  width: 1.35rem;
  height: 0.55rem;
  background: var(--hero);
  flex: none;
}

/* No flex `gap` here: the wordmark is a bare text node plus a <span>, so a gap
   would open a hole between "flossypurse" and ".studio". The icon carries its
   own margin instead. */
.brand {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.035em;
  color: var(--fg);
  text-decoration: none;
}
.brand svg, .brand img { width: 1.85rem; height: 1.85rem; flex: none; display: block; margin-right: 0.6rem; }
.brand .dim { color: var(--hero); font-weight: 800; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.25rem; }

.btn {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  border: 2px solid var(--fg);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--small);
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
}
.btn:hover { background: var(--fg); color: var(--bg); }
.btn-primary { background: var(--hero-ink); border-color: var(--hero-ink); color: #fff; }
.btn-primary:hover { background: var(--hero-ink-deep); border-color: var(--hero-ink-deep); color: #fff; }

/* ---------- cards ---------- */

.cards { display: grid; gap: 0.75rem; }
@media (min-width: 44em) { .cards { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.6rem 1.35rem;
}
.card p { color: var(--fg-dim); font-size: var(--small); margin-top: 0.7rem; }
.card .links { margin-top: 1rem; display: flex; gap: 1rem; font-size: var(--micro); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem 0 3rem;
  font-family: var(--font-mono);
  font-size: var(--micro);
  color: var(--fg-mute);
}
footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 3rem;
  justify-content: space-between;
  align-items: flex-start;
}

/* identity block, left */
.foot-id { display: flex; align-items: flex-start; gap: 0.75rem; }
.foot-id img { flex: none; opacity: 0.7; margin-top: 0.1rem; }
.foot-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--small);
  letter-spacing: -0.02em;
  color: var(--fg);
}
.foot-note { margin: 0.25rem 0 0; }
.foot-legal { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; }
.foot-legal a { color: var(--fg-mute); text-decoration: none; }
.foot-legal a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

/* elsewhere block, right — two tiers of prominence */
.foot-elsewhere { max-width: 26rem; }
.foot-label {
  margin: 0 0 0.75rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.foot-primary,
.foot-secondary { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }

.foot-primary { gap: 0.5rem 1.5rem; }
.foot-primary a {
  font-family: var(--font-body);
  font-size: var(--small);
  font-weight: 500;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}
.foot-primary a:hover {
  color: var(--hero-ink);
  text-decoration-color: rgba(214, 48, 24, 0.5);
}

.foot-secondary { gap: 0.35rem 1.25rem; margin-top: 0.9rem; }
.foot-secondary a { color: var(--fg-mute); text-decoration: none; }
.foot-secondary a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 640px) {
  footer .wrap { gap: 1.75rem; }
  .foot-elsewhere { max-width: none; }
}

[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::selection { background: var(--hero-ink); color: #fff; }

/* =====================================================================
   App shell.

   The studio reads like an app, not a brochure: a rail on the left from 60em
   up (five destinations, the active one opening its own sub-list), a top bar
   and a bottom tab bar below that, a search palette on Cmd-K. Page to page
   is a cross-document view transition, so the rail stays put and only the
   stage moves. Plain static HTML underneath; nothing here needs JavaScript
   except the palette.
   ===================================================================== */

@view-transition { navigation: auto; }
.rail { view-transition-name: rail; }
.tabbar { view-transition-name: tabbar; }
.topbar { view-transition-name: topbar; }
.stage { view-transition-name: stage; }
::view-transition-old(stage) { animation: 140ms ease-in both stage-out; }
::view-transition-new(stage) { animation: 220ms cubic-bezier(.2,.7,.2,1) both stage-in; }
@keyframes stage-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes stage-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(stage), ::view-transition-new(stage) { animation: none; }
}

body.app { min-height: 100vh; }
.stage { min-width: 0; }
.stage > footer { margin-top: 2rem; }
.ico { flex: none; display: block; }
kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.3rem;
  color: var(--fg-mute);
  background: var(--surface);
}

/* ---------- top bar + tab bar (small screens) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.25rem;
  background: rgba(251, 247, 240, 0.9);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-actions { display: flex; gap: 0.25rem; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: var(--micro);
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[aria-current] { color: var(--hero-ink); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  /* One column per tab, however many there are. Six at 360px is ~58px each,
     enough for a 22px icon over the longest label ("Studio"). */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.3rem 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg-mute);
  text-decoration: none;
}
.tabbar a[aria-current] { color: var(--hero-ink); }
.tabbar a[aria-current] .ico { stroke-width: 2.2; }
body.app .stage { padding-bottom: 4.5rem; }

.rail { display: none; }

/* ---------- rail (60em and up) ---------- */

@media (min-width: 60em) {
  body.app { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  body.app .stage { padding-bottom: 0; }

  .rail {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.5rem 1rem 1.25rem;
    border-right: 1px solid var(--line);
    background: var(--surface-2);
  }
  .rail .brand { padding: 0 0.5rem; }
  .search-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--fg-mute);
    font: inherit;
    font-size: var(--small);
    cursor: pointer;
    text-align: left;
  }
  .search-btn span { flex: 1; }
  .search-btn .ico { width: 18px; height: 18px; }
  .search-btn:hover { border-color: var(--fg-mute); color: var(--fg); }

  .rail-tabs, .rail-sub { list-style: none; margin: 0; padding: 0; }
  .rail-tabs { display: grid; gap: 0.15rem; }
  .rail-tab {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem;
    border-radius: 9px;
    color: var(--fg-dim);
    font-weight: 600;
    text-decoration: none;
  }
  .rail-tab:hover { background: var(--line-soft); color: var(--fg); }
  .rail-tabs li.on > .rail-tab { background: var(--surface); color: var(--fg); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line); }
  .rail-tabs li.on > .rail-tab .ico { color: var(--hero); }
  .rail-sub { margin: 0.35rem 0 0.5rem 1.55rem; padding-left: 0.95rem; border-left: 1px solid var(--line); display: grid; gap: 0.05rem; }
  .rail-sub a {
    display: block;
    padding: 0.28rem 0.5rem;
    border-radius: 6px;
    font-size: var(--small);
    color: var(--fg-dim);
    text-decoration: none;
  }
  .rail-sub a:hover { color: var(--fg); background: var(--line-soft); }
  .rail-sub a[aria-current] { color: var(--hero-ink); font-weight: 600; }

  .rail-foot { margin-top: auto; display: grid; gap: 0.6rem; }
  .rail-cart {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.7rem;
    color: var(--fg-dim);
    font-size: var(--small);
    font-weight: 500;
    text-decoration: none;
  }
  .rail-cart:hover { color: var(--fg); }
  /* The studio account (FPS_ACCOUNTS=1): no tab of its own, so on /account
     this link carries the "you are here" the tabs carry elsewhere. */
  .rail-account {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.7rem;
    border-radius: 9px;
    color: var(--fg-dim);
    font-size: var(--small);
    font-weight: 500;
    text-decoration: none;
  }
  .rail-account:hover { color: var(--fg); }
  .rail-account[aria-current] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line); }
  .rail-account[aria-current] .ico { color: var(--hero); }
  .rail-account-name { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--micro); color: var(--fg-mute); }
  .rail-cta { justify-content: center; text-align: center; }
}

/* ---------- palette ---------- */

.palette {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 1rem;
  background: rgba(22, 24, 29, 0.32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.palette[hidden] { display: none; }
html.palette-open { overflow: hidden; }
.palette-box {
  width: 100%;
  max-width: 36rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(22, 24, 29, 0.22);
  overflow: hidden;
  animation: pal-in 160ms cubic-bezier(.2,.7,.2,1);
}
@keyframes pal-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }
.palette-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.15rem;
  font: inherit;
  font-size: 1.05rem;
  background: none;
  color: var(--fg);
  outline: none;
}
.palette-list { list-style: none; margin: 0; padding: 0.4rem; max-height: 52vh; overflow-y: auto; }
.palette-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
}
.palette-list [aria-selected=true] a { background: var(--hero-wash); }
.palette-title { font-weight: 500; }
.palette-kind { font-family: var(--font-mono); font-size: var(--micro); color: var(--fg-mute); white-space: nowrap; }
.palette-empty { padding: 0.9rem 0.75rem; color: var(--fg-mute); font-size: var(--small); }
.palette-hint { margin: 0; padding: 0.55rem 1rem; border-top: 1px solid var(--line); font-size: var(--micro); color: var(--fg-mute); display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }

/* The rail's shade runs the full height of the page, not just the viewport. */
@media (min-width: 60em) {
  body.app { background: linear-gradient(to right, var(--surface-2) calc(15.5rem - 1px), var(--line) calc(15.5rem - 1px), var(--line) 15.5rem, var(--bg) 15.5rem); }
  .rail { border-right: 0; background: none; }
}

/* ---------- review fixes: contrast, safe area, motion, skip link ---------- */

.tabbar a { color: var(--fg-dim); }
body.app .stage { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
@media (min-width: 60em) { body.app .stage { padding-bottom: 0; } }
.search-btn, .palette-kind, .palette-hint, kbd { color: var(--fg-dim); }
@media (min-width: 60em) { .rail-sub a[aria-current] { color: var(--fg); box-shadow: inset 2px 0 0 var(--hero); } }
.palette-box:focus-within { outline: 2px solid var(--hero); outline-offset: 2px; }
.skip { position: absolute; left: 0.75rem; top: -3rem; z-index: 60; padding: 0.5rem 0.9rem; border-radius: 8px; background: var(--fg); color: #fff; text-decoration: none; }
.skip:focus { top: 0.75rem; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .palette-box { animation: none; }
}

/* ---------- phones and touch (see the note in styles.css) ---------- */

@media (max-width: 59.99em) {
  .wrap {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }
  .topbar {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }
  .tabbar {
    padding-left: max(0.25rem, env(safe-area-inset-left));
    padding-right: max(0.25rem, env(safe-area-inset-right));
  }
}
@media (min-width: 44em) and (max-width: 59.99em) {
  .wrap {
    padding-left: max(2rem, env(safe-area-inset-left));
    padding-right: max(2rem, env(safe-area-inset-right));
  }
}

/* Sideways on a phone the two bars took a third of the height: the tab bar
   sets its icon beside its label, and the top bar slims down. */
@media (max-width: 59.99em) and (max-height: 30em) and (orientation: landscape) {
  .topbar { padding-top: 0.35rem; padding-bottom: 0.35rem; }
  .tabbar a { flex-direction: row; justify-content: center; gap: 0.4rem; padding: 0.55rem 0; }
  .tabbar .ico { width: 20px; height: 20px; }
  body.app .stage { padding-bottom: calc(3.25rem + env(safe-area-inset-bottom)); }
}

@media (pointer: coarse) {
  .icon-btn { min-width: 44px; min-height: 44px; justify-content: center; }
  .topbar { padding-top: 0.45rem; padding-bottom: 0.45rem; }
  /* A tapped button keeps :hover on a phone until the next tap elsewhere. */
  .icon-btn:hover { background: none; }
  .icon-btn:active { background: var(--surface-2); }

  /* the palette's key hints mean nothing without a keyboard */
  .palette-hint { display: none; }
}
