/* The family: the frame every app on Tardis shares.
   Header, tab bar (a sidebar on a computer), the app switcher sheet, type, spacing and shapes.
   One file, the same in every app: copy it to all of them when it changes.

   Each app gives its own personality in its own stylesheet, by setting these (light, and dark in
   @media (prefers-color-scheme: dark)):
     --bg --surface --surface-2 --text --text-2 --text-3 --line
     --accent (text and icons in the accent colour; readable on --bg and --surface)
     --accent-fill (filled buttons) --on-accent (text on them)
     --brand (the app's icon colour) --bar (the frosted header and tab bar)
     --face (the app's own typeface, for its content: titles, stories, recipes) */

@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --face: var(--ui);
  /* 8 px steps */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* shapes */
  --r-card: 14px; --r-sheet: 22px; --r-mark: 8px; --tap: 44px;
  /* sizes */
  --header-h: 52px; --tabbar-h: 56px; --sidebar-w: 248px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- the header: app mark and name on the left, search and the app switcher on the right ---------- */
.fam-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  height: calc(var(--header-h) + var(--safe-top)); padding: var(--safe-top) 6px 0 16px;
  background: var(--bar); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
}
.fam-mark { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-mark); background: var(--brand); color: #fff; }
.fam-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.fam-name { flex: 1; min-width: 0; font: 600 1.06rem/1 var(--ui); letter-spacing: -.01em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-iconbtn {
  flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 12px;
  background: none; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color .12s ease-out, transform .1s ease-out;
}
.fam-iconbtn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.fam-iconbtn:active, .fam-iconbtn.is-pressed { transform: scale(.92); }
.fam-iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the tab bar: along the bottom on a phone, labelled ---------- */
.fam-tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + var(--safe-bottom)); background: var(--bar); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
}
.fam-tabbar > button, .fam-tabbar > a {
  flex: 1 1 0; max-width: 96px; min-height: var(--tap); display: grid; justify-items: center; align-content: center; gap: 2px;
  padding: 4px 0; border: 0; border-radius: 12px; background: none; cursor: pointer; text-decoration: none;
  color: var(--text-2); font: 500 .69rem/1.1 var(--ui); letter-spacing: .01em; -webkit-tap-highlight-color: transparent;
  transition: color .15s ease, transform .1s ease-out;
}
.fam-tabbar > button svg, .fam-tabbar > a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.fam-tabbar > [aria-selected="true"], .fam-tabbar > [aria-current="page"] { color: var(--accent); font-weight: 650; }
.fam-tabbar > :active, .fam-tabbar > .is-pressed { transform: scale(.94); }

/* ---------- your apps: a list (the sidebar on a computer, the switcher sheet on a phone) ---------- */
.fam-apps { display: grid; gap: 2px; }
.fam-apps-head { margin: 0 12px 6px; font: 650 .7rem/1 var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.fam-app-link {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 6px 10px; border-radius: 12px;
  color: var(--text); text-decoration: none; font: 500 .95rem/1.2 var(--ui); -webkit-tap-highlight-color: transparent;
  transition: background-color .12s ease-out, transform .1s ease-out;
}
.fam-app-link:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.fam-app-link:active, .fam-app-link.is-pressed { transform: scale(.98); }
.fam-app-link[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 650; }
.fam-app-icon { flex: none; width: 30px; height: 30px; border-radius: var(--r-mark); overflow: hidden; display: grid; place-items: center; font-size: 1.05rem; background: var(--surface-2); }
.fam-app-icon img { width: 100%; height: 100%; display: block; object-fit: cover; }
.fam-app-link .fam-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.fam-app-link .fam-dot.up { background: #2fb36b; } .fam-app-link .fam-dot.down { background: #e5484d; }

/* ---------- the switcher sheet ---------- */
.fam-sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: min(80vh, 640px);
  padding: 8px 12px calc(16px + var(--safe-bottom)); border: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--surface); color: var(--text); box-shadow: 0 -8px 40px rgba(0, 0, 0, .22); overflow: auto;
}
.fam-sheet::backdrop { background: rgba(0, 0, 0, calc(.36 * var(--scrim, 1))); }
.fam-grabber { width: 36px; height: 5px; margin: 0 auto 10px; border-radius: 3px; background: var(--line-strong, var(--text-3)); opacity: .6; }
.fam-sheet h2 { margin: 2px 10px 12px; font: 700 1.2rem/1.2 var(--ui); letter-spacing: -.01em; }
@media (min-width: 700px) {
  .fam-sheet { inset: 0; margin: auto; width: min(420px, 92vw); max-height: min(80vh, 640px); border-radius: var(--r-sheet); padding: 16px 12px; }
  .fam-sheet .fam-grabber { display: none; }
}

/* ---------- on a computer: the tab bar becomes a sidebar, with your apps under it ----------
   Markup: <div class="fam-shell"> header.fam-header, <div class="fam-rail"> nav.fam-tabbar + nav.fam-side </div>, main </div> */
.fam-rail { display: contents; }
.fam-side { display: none; }
@media (min-width: 900px) {
  .fam-shell { padding-left: var(--sidebar-w); }
  .fam-shell .fam-header {
    position: fixed; left: 0; top: 0; z-index: 31; width: var(--sidebar-w); height: auto; padding: calc(20px + var(--safe-top)) 10px 8px 22px;
    background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .fam-shell .fam-header [data-fam="switch"] { display: none; } /* your apps are always in view */
  .fam-shell .fam-rail {
    display: flex; flex-direction: column; position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
    padding: calc(80px + var(--safe-top)) 12px 20px; border-right: 1px solid var(--line); background: var(--sidebar, var(--bg)); overflow-y: auto;
  }
  .fam-shell .fam-tabbar {
    position: static; flex-direction: column; justify-content: flex-start; gap: 2px; padding: 0; border: 0;
    background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .fam-shell .fam-tabbar > button, .fam-shell .fam-tabbar > a {
    flex: none; max-width: none; display: flex; align-items: center; justify-content: flex-start; gap: 12px; min-height: 40px; padding: 0 12px;
    font-size: .92rem; font-weight: 500; letter-spacing: 0; color: var(--text);
  }
  .fam-shell .fam-tabbar > button svg, .fam-shell .fam-tabbar > a svg { width: 20px; height: 20px; color: var(--text-2); }
  .fam-shell .fam-tabbar > [aria-selected="true"], .fam-shell .fam-tabbar > [aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); font-weight: 650; }
  .fam-shell .fam-tabbar > [aria-selected="true"] svg, .fam-shell .fam-tabbar > [aria-current="page"] svg { color: var(--accent); }
  .fam-shell .fam-side { display: grid; margin-top: 26px; }
}

/* ---------- things every app shares ---------- */
.fam-face { font-family: var(--face); }
@media (prefers-reduced-motion: reduce) {
  .fam-iconbtn, .fam-tabbar > *, .fam-app-link { transition: none; }
  .fam-iconbtn:active, .fam-tabbar > :active, .fam-app-link:active, .is-pressed { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .fam-header, .fam-tabbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
}
