/* Site chrome: header, phone layout, motion and touch.
   Lives outside index.html so a re-export from Claude Design only needs the class hooks re-added. */

:root {
  --ink: #121212;
  --paper: #f3f0e8;
  --acid: oklch(0.9 0.19 118);
  --pink: oklch(0.72 0.2 350);
  --zh-h: 64px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--zh-h) + 12px);
}

body { -webkit-tap-highlight-color: transparent; }

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

/* ---------- Header ---------- */
.zh {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
  padding-top: env(safe-area-inset-top);
  transition: transform .25s ease;
}

.zh-in {
  max-width: 1240px;
  margin: 0 auto;
  min-height: var(--zh-h);
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 20px;
}

.zh-brand {
  background: none;
  border: none;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  flex: none;
  min-height: 44px;
}

.zh-mark {
  background: var(--ink);
  color: var(--paper);
  font-weight: 900;
  font-stretch: 75%;
  font-size: 22px;
  padding: 4px 8px;
  line-height: 1;
  transform: rotate(-4deg);
  display: inline-block;
}

.zh-name {
  font-weight: 800;
  font-stretch: 80%;
  font-size: 17px;
  text-transform: uppercase;
  line-height: 1;
}

.zh-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.zh-link {
  background: none;
  border: none;
  padding: 10px 10px;
  min-height: 44px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  position: relative;
}

.zh-link::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  height: 3px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .15s ease;
}

.zh-link:hover::after { transform: scaleX(1); }

.zh-link[aria-current="page"] { background: var(--acid); }
.zh-link[aria-current="page"]::after { transform: scaleX(1); }

.zh-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.zh-icon {
  background: #fff;
  border: 2px solid var(--ink);
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
}

.zh-icon:hover { background: var(--acid); }

.zh-glass {
  width: 14px;
  height: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  position: relative;
  display: inline-block;
  flex: none;
}

.zh-glass::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2.5px;
  background: var(--ink);
  right: -6px;
  bottom: -4px;
  transform: rotate(45deg);
}

.zh-kbd {
  border: 1.5px solid var(--ink);
  padding: 0 5px;
  font-size: 11px;
  font-family: inherit;
}

.zh-menu {
  background: var(--ink);
  color: var(--paper);
  flex-direction: column;
  gap: 4px;
  width: 44px;
  padding: 0;
}

.zh-menu span { width: 20px; height: 3px; background: currentColor; display: block; }
.zh-menu:hover { background: var(--pink); color: var(--ink); }

.zh-book {
  background: var(--pink);
  border: 2px solid var(--ink);
  height: 44px;
  padding: 0 14px;
  font-weight: 900;
  font-stretch: 85%;
  font-size: 15px;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--ink);
  white-space: nowrap;
  transition: transform .1s, box-shadow .1s;
}

.zh-book:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.zh-short { display: none; }

/* Four text links fit down to tablet width; below that they move into the menu. */
@media (max-width: 899px) {
  .zh-nav { display: none; }
  .zh-actions { margin-left: auto; }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  :root { --zh-h: 60px; }

  .zh-in { gap: 10px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .zh-mark { font-size: 19px; }
  .zh-name { font-size: 13.5px; }
  .zh-actions { gap: 6px; }
  /* Search and Book move to the bottom tab bar, within thumb reach. */
  .zh-search, .zh-book { display: none; }

  /* Header gets out of the way while reading and returns on scroll up. */
  html[data-nav="hide"] .zh { transform: translateY(-100%); }

  /* Ticker is decoration; on a phone it costs a line of screen for no information. */
  .zt { display: none !important; }

  /* Hero: headline uses the full width; sticker shrinks and sits clear of the tags. */
  .hero-in { padding: 28px 16px 44px !important; }
  .hero-tags { padding-right: 92px; font-size: 11.5px !important; gap: 6px !important; }
  .hero-h1 { max-width: 100% !important; font-size: clamp(46px, 15.5vw, 72px) !important; line-height: .88 !important; }
  .hero-sticker { width: 84px !important; height: 84px !important; font-size: 13.5px !important; padding: 8px !important; top: 18px !important; right: 12px !important; }

  /* Full-screen menu and search, with room for the home indicator. */
  .zd { width: 100vw !important; box-shadow: none !important; border-left: none !important; padding-bottom: env(safe-area-inset-bottom); }
  .zs { top: 0 !important; left: 0 !important; transform: none !important; width: 100vw !important; max-height: 100dvh !important; height: 100dvh; border: none !important; box-shadow: none !important; padding-top: env(safe-area-inset-top); }

  /* iOS zooms into inputs under 16px. */
  input, select, textarea { font-size: max(16px, 1em) !important; }
}

/* ---------- Home "Next up" card (phones) ---------- */
@media (max-width: 640px) {
  /* Side-by-side layout left the title ~150px wide, so long titles ran off the card. Stack instead. */
  .nu { transform: rotate(.6deg) !important; box-shadow: 6px 6px 0 var(--ink) !important; max-width: calc(100% - 6px) !important; }
  .nu-body { flex-direction: column !important; gap: 14px !important; padding: 16px !important; }
  .nu-date { display: flex; align-items: baseline; gap: 12px; text-align: left !important; border-right: none !important; padding-right: 0 !important; border-bottom: 3px dashed var(--ink); padding-bottom: 12px; }
  .nu-date > div { margin-top: 0 !important; }
  .nu-day { font-size: 64px !important; }
  .nu-title { font-size: clamp(26px, 8.5vw, 34px) !important; }
  .nu-btn { width: 100%; min-height: 48px; font-size: 15px !important; }
}

/* ---------- Narrow phones: long words and URLs ---------- */
@media (max-width: 640px) {
  /* Page headlines have a 52-56px floor; on a 360px Android a word like DOOMSCROLL. ran past the edge. */
  main h1:not(.hero-h1) { font-size: min(56px, 13.5vw) !important; overflow-wrap: break-word; }
  /* Long web addresses wrap instead of pushing out of their card. */
  main a { overflow-wrap: anywhere; }
}

/* Smallest phones (320-360px, e.g. first-gen iPhone SE). */
@media (max-width: 360px) {
  main h2 { font-size: min(40px, 11.5vw) !important; overflow-wrap: break-word; }
  .svc-title { font-size: 30px !important; }
}

/* ---------- Bottom tab bar (phones) ---------- */
.zb { display: none; }

@media (max-width: 640px) {
  .zb {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--paper);
    border-top: 3px solid var(--ink);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .zb-tab {
    background: none;
    border: none;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    position: relative;
  }

  .zb-tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  .zb-tab[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 4px;
    background: var(--ink);
  }

  .zb-tab[aria-current="page"] svg { fill: var(--acid); }

  .zb-book { background: var(--pink); border-left: 3px solid var(--ink); }
  .zb-book[aria-current="page"]::before { display: none; }

  /* Keep the footer clear of the bar. (The app renders inside its own box, so body padding has no effect.) */
  footer { margin-bottom: calc(59px + env(safe-area-inset-bottom)); }

  /* Out of the way while typing (the on-screen keyboard would push it up). */
  body:has(input:focus, textarea:focus, select:focus) .zb { display: none; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .zh, .zh-link::after, .zh-book { transition: none; }
  .zt * { animation: none !important; }
  html { scroll-behavior: auto; }
}

/* Calendar grid (#calendar): titles on wide screens, dots on phones; the list below the grid carries the detail. */
.zcal-cell { min-height: 112px; }
.zcal-chip-d { display: none; }
@media (max-width: 760px) {
  .zcal-cell { min-height: 58px; padding: 4px !important; }
  .zcal-chip { padding: 0 !important; border: none !important; background: none !important; text-align: center !important; margin-top: 0 !important; }
  .zcal-chip-t, .zcal-chip-k, .zcal-chip-s { display: none !important; }
  .zcal-chip-d { display: inline; font-size: 16px; line-height: 1; color: #121212; }
}

/* "Skip to content": hidden until a keyboard user tabs to it. */
.zpc-skip { position: absolute; left: 12px; top: -60px; z-index: 200; background: #121212; color: #f3f0e8; border: 3px solid #121212; padding: 10px 14px; font-weight: 900; text-transform: uppercase; }
.zpc-skip:focus { top: 12px; outline: 3px solid oklch(0.72 0.2 350); }

/* Project tracker (#projects): the current stage pulses, like the pizza tracker. */
@keyframes ztrkPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.ztrk-now { animation: ztrkPulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ztrk-now { animation: none; } }
@media (max-width: 640px) {
  .ztrk-sub { display: none; }
  .ztrk-row { grid-template-columns: minmax(0,1fr) auto !important; }
  .ztrk-row > span:nth-child(2) { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 640px) { .zwf-row { grid-template-columns: 1fr !important; } }
/* Workflow board below desktop: stages wrap into as many columns as fit (3 on a tablet, 1 on a phone) instead of scrolling sideways. */
@media (max-width: 1100px) {
  .zwf-board { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important; min-width: 0 !important; border: none !important; gap: 12px; }
  .zwf-col { border: 2px solid #121212 !important; }
}
/* Calendar chips on tablets: wrap long words, drop the topic line to save room. */
.zcal-chip-t { overflow-wrap: break-word; hyphens: auto; }
@media (max-width: 1100px) and (min-width: 761px) {
  .zcal-chip-k { display: none !important; }
  .zcal-chip { font-size: 11.5px !important; padding: 3px 5px !important; }
  .zcal-chip-t { display: none; }
  .zcal-chip-s { display: inline !important; }
}
.zcal-chip-s { display: none; }

/* Home "This week": seven columns on wide screens; a list of days with events on phones. */
@media (max-width: 760px) {
  .zwk-grid { grid-template-columns: 1fr !important; }
  .zwk-day { border-left: none !important; border-top: 2px solid #121212; min-height: 0 !important; }
  .zwk-day:first-child { border-top: none; }
  .zwk-empty:not(.zwk-keep) { display: none; }
}

/* About "Tap everything that's true": checklist takes the width, score is a narrow sticky sidebar.
   Below 860px the score becomes a slim bar pinned above the phone tab bar while you tick boxes. */
@media (max-width: 860px) {
  .zsurf { grid-template-columns: 1fr !important; }
  .zsurf-score { top: auto !important; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); padding: 10px 14px !important; box-shadow: 4px 4px 0 #121212 !important;
    display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; z-index: 5; }
  .zsurf-top { grid-row: span 2; display: flex; align-items: baseline; gap: 8px; }
  .zsurf-num { font-size: 44px !important; margin-top: 0 !important; }
  .zsurf-bar { margin-top: 0 !important; height: 10px !important; }
  .zsurf-verdict { margin-top: 0 !important; font-size: 17px !important; }
  .zsurf-more { display: none !important; }
}
@media (min-width: 761px) and (max-width: 860px) { .zsurf-score { bottom: 12px; } }
/* Phones: checklist in two columns, titles only. */
@media (max-width: 560px) {
  .zsurf-grid { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .zsurf-grid .zsurf-d { display: none; }
  .zsurf-grid button { padding: 8px !important; gap: 7px !important; }
}

/* Tools and Commons: each category is one box of compact rows; boxes flow into columns side by side
   instead of every category starting its own half-empty row of big cards. */
.zlist-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; align-items: start; }
.zlist-row:first-of-type { border-top: none; }
/* News: two-line summaries in the headline grid. */
.znews-x { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Fails "At a glance": fits tablets; on phones each row becomes a card with labeled cells. */
@media (max-width: 900px) { .zg-row > div, .zg-head > div { padding: 8px 8px !important; } .zg-row { font-size: 13.5px !important; } }
@media (max-width: 640px) {
  .zg-head { display: none !important; }
  .zg-row { grid-template-columns: 1fr 1fr !important; }
  .zg-row .zg-s { grid-column: 1 / -1; }
  .zg-row > div[data-l]::before { content: attr(data-l); display: block; font-family: "Space Mono", monospace; font-size: 10.5px; font-weight: 700; text-transform: uppercase; opacity: .75; }
}

/* Simple / All switch in the header (stays visible on phones: it's how people get back). */
.zh-mode { display: inline-flex; border: 2px solid var(--ink, #121212); background: #fff; padding: 0; height: 36px; align-items: stretch; font-family: "Space Mono", monospace; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.zh-mode span { display: flex; align-items: center; padding: 0 9px; }
.zh-mode span + span { border-left: 2px solid var(--ink, #121212); }
.zh-mode:hover span { text-decoration: underline; }
@media (max-width: 640px) { .zh-mode { height: 32px; font-size: 11px; } .zh-mode span { padding: 0 7px; } }
