/* ============================================================
   Through My Eyes — companion site
   Design system. See DESIGN-NOTES.md for rationale.
   ============================================================ */

/* ---- Fonts (CDN with graceful fallback) ---- */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600;6..72,700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

/* ---- Tokens ---- */
:root {
  --paper: #F6F3EC;
  --ink: #1B1E23;
  --viewing: #14171C;
  --viewing-ink: #EDEAE3;
  --accent: #3A6EA5;
  --accent-ink: #2A527D; /* darker accent for AA text on paper */
  --accent-2: #C6752F;
  --muted: #5B6169;
  --line: #D9D3C7;
  --viewing-line: #2C333C;

  --display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --body: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --measure: 65ch;
  --gap: clamp(1rem, 2vw, 1.5rem);
  --section-y: clamp(1.25rem, 3vw, 2.25rem);
  --radius: 14px;
}

/* ---- Reset-ish ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1.05rem, 0.5vw + 1rem, 1.2rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-underline-offset: 0.18em; text-decoration-thickness: 0.08em; }
a:hover { text-decoration-thickness: 0.14em; }

/* ---- Skip link + focus ---- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 0.7em 1em; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* ---- Layout primitives ---- */
.wrap { width: min(100% - 2.5rem, 74rem); margin-inline: auto; }
.measure { max-width: var(--measure); }
.section { padding-block: var(--section-y); }

/* ---- Typography ---- */
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.4rem, 5vw + 1rem, 4.2rem); font-weight: 600; }
h2 { font-size: clamp(1.7rem, 2.5vw + 1rem, 2.6rem); margin-top: 0; }
h3 { font-size: clamp(1.25rem, 1vw + 1rem, 1.6rem); }
p { margin: 0 0 1.1em; }
.lead { font-size: clamp(1.2rem, 1vw + 1.05rem, 1.5rem); line-height: 1.5; color: var(--ink); }
.eyebrow {
  font-family: var(--body); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; font-size: 0.92rem; color: var(--ink); margin: 0 0 0.9rem;
}
.eyebrow::before {
  content: ""; display: inline-block; width: 1.4em; height: 0.14em; vertical-align: middle;
  background: var(--accent); margin-right: 0.5em; border-radius: 2px;
}
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* ---- Header / nav ---- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; }
.brand { font-family: var(--display); font-weight: 600; font-size: 1.2rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 0.55rem; }
.brand .brand-mark {
  width: 1.7em; height: 1.7em; border-radius: 7px;
  flex: none; display: inline-block; object-fit: cover;
  border: 1px solid var(--viewing-line);
}
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem 0.35rem; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; padding: 0.4rem 0.7rem; border-radius: 8px; font-weight: 500; font-size: 0.98rem; }
.nav a:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.nav a[aria-current="page"] { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 0.12em; }
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem; background: none; border: 1px solid var(--line);
    border-radius: 8px; padding: 0.45rem 0.7rem; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
  }
  .nav { display: none; position: absolute; top: 64px; right: 1.25rem; left: 1.25rem;
    flex-direction: column; align-items: stretch; background: var(--paper); border: 1px solid var(--line);
    border-radius: 12px; padding: 0.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.12); }
  .nav.open { display: flex; }
  .nav a { padding: 0.7rem 0.8rem; }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; font: inherit; font-weight: 600;
  padding: 0.7rem 1.15rem; border-radius: 10px; text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); }

/* ---- The signature: viewing frame ---- */
.viewing {
  background: var(--viewing); color: var(--viewing-ink);
  border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.75rem);
  border: 1px solid var(--viewing-line);
}
.viewing .pair { display: grid; gap: 0.9rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .viewing .pair { grid-template-columns: 1fr; } }
.frame {
  position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden;
  background:
    repeating-linear-gradient(45deg, #1b1f26 0 12px, #191d24 12px 24px);
  display: grid; place-items: center; text-align: center; border: 1px solid var(--viewing-line);
}
.frame .ph {
  font-size: 0.85rem; color: #9aa2ad; padding: 1rem; line-height: 1.4;
}
.frame .ph strong { color: #c3cad3; display: block; font-family: var(--display); font-size: 1rem; margin-bottom: 0.3rem; }
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame-label {
  position: absolute; left: 0.6rem; bottom: 0.6rem; z-index: 2;
  background: rgba(10,12,15,0.78); color: #eef1f5; font-size: 0.78rem; font-weight: 600;
  padding: 0.28rem 0.6rem; border-radius: 6px; letter-spacing: 0.01em;
}
.viewing figcaption { margin-top: 0.9rem; font-size: 0.9rem; color: #b9c0c9; }

/* ---- Cards / filter index ---- */
.groups { display: grid; gap: var(--section-y); }
.group-intro { border-left: 3px solid var(--accent); padding-left: 1rem; }
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 1.5rem; }
.card {
  display: flex; flex-direction: column; gap: 0.5rem; text-decoration: none; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .card-thumb {
  aspect-ratio: 3 / 2; border-radius: 8px; background: var(--viewing); border: 1px solid var(--viewing-line);
  display: grid; place-items: center; color: #8a929c; font-size: 0.75rem; text-align: center; padding: 0.5rem;
}
.card h3 { margin: 0.2rem 0 0; font-size: 1.15rem; }
.card .card-tag { font-size: 0.78rem; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.card .card-tag::before { content: ""; width: 0.6em; height: 0.6em; border-radius: 2px; background: var(--accent); flex: none; }
/* tag shape differs per group so color is never the only cue */
.card .card-tag.tag-animal::before { border-radius: 50%; }
.card .card-tag.tag-condition::before { border-radius: 2px; }
.card .card-tag.tag-color::before { border-radius: 2px; transform: rotate(45deg); }

/* ---- Filter page ---- */
.filter-hero { display: grid; gap: 1.5rem; }
.whatwhy { display: grid; gap: var(--gap); margin-top: 2rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: clamp(1.1rem, 2.5vw, 1.8rem); }
/* When jumped to via an anchor (e.g. #grayscale), land below the top so the heading is
   visible. Desktop browsers have no top chrome over the page, so a small margin suffices. */
.panel[id] { scroll-margin-top: 1.5rem; }
/* On narrow (mobile) viewports the page may open inside an in-app browser
   (SFSafariViewController) whose tall top toolbar overlays the content, so give anchored
   sections extra clearance there without affecting the desktop layout. */
@media (max-width: 640px) {
  .panel[id] { scroll-margin-top: 4.5rem; }
}
.panel h2 { display: flex; align-items: baseline; gap: 0.6rem; }
.panel .tagword { font-family: var(--body); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-ink); }

.panel.livecam { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, #fff); }
.panel.livecam .tagword::before {
  content: ""; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%;
  background: var(--accent); margin-right: 0.45em; vertical-align: middle;
}

details.deeper {
  margin-top: 1rem; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--accent) 5%, #fff);
}
details.deeper > summary {
  cursor: pointer; padding: 0.9rem 1.1rem; font-weight: 600; color: var(--accent-ink);
  list-style: none; display: flex; align-items: center; gap: 0.5rem;
}
details.deeper > summary::-webkit-details-marker { display: none; }
details.deeper > summary::before { content: "＋"; font-weight: 700; }
details.deeper[open] > summary::before { content: "－"; }
details.deeper > summary:hover { text-decoration: underline; }
details.deeper .deeper-body { padding: 0 1.1rem 1.1rem; }

.sources { margin-top: 2rem; }
.sources ol { padding-left: 1.3rem; }
.sources li { margin-bottom: 0.6rem; font-size: 0.92rem; color: var(--ink); }
.sources a { word-break: break-word; }
.sup { font-size: 0.7em; vertical-align: super; color: var(--accent-ink); font-weight: 700; text-decoration: none; }

/* ---- Callouts ---- */
.note {
  border-left: 3px solid var(--accent-2); background: color-mix(in srgb, var(--accent-2) 8%, #fff);
  padding: 1rem 1.1rem; border-radius: 0 10px 10px 0; margin: 1.5rem 0;
}
.note strong { color: color-mix(in srgb, var(--accent-2) 70%, var(--ink)); }

/* ---- Hero (home) ---- */
.hero { padding-block: clamp(1.75rem, 4vw, 3rem); }
.hero .lead { max-width: 40ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* ---- Footer ---- */
.site-foot { background: var(--viewing); color: var(--viewing-ink); padding-block: 3rem; margin-top: var(--section-y); }
.site-foot a { color: #bcd0e6; }
.site-foot .cols { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.site-foot h4 { font-family: var(--body); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; color: #9aa2ad; }
.site-foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.site-foot .fine { margin-top: 2rem; font-size: 0.85rem; color: #9aa2ad; }

/* ---- Forms ---- */
.field { display: grid; gap: 0.4rem; margin-bottom: 1.1rem; }
.field label { font-weight: 600; }
.field .hint { font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin: 0 0 1.1rem; }
legend { font-weight: 600; padding: 0 0.4rem; }

/* ---- Utility ---- */
.stack > * + * { margin-top: 1.1rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 600;
  padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
