/* styles.css — Tip or Nah?  Vanilla, mobile-first, zero runtime deps.
   Identity: a receipt / "permission slip". Display serif (Fraunces) for the wordmark + headings,
   monospace for money, paper background, rubber-stamp verdicts. Verdict meaning is carried by
   SHAPE (icon) + TEXT + colour, so it survives colour-blindness and platform emoji differences.
   All verdict chips use solid fill + white text → WCAG AA clears comfortably. */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-900.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

:root {
  --bg: #f7f3ea;
  --paper: #fffdf8;
  --surface: #ffffff;
  --ink: #211d18;
  --muted: #6a6256;
  --line: #e4dccc;
  --rule: #cfc6b2;
  --accent: #b3412e;          /* warm ink-red accent (the "?" + brand) */
  --accent-ink: #ffffff;
  --link: #9a3727;
  /* Verdict colours — solid fills, white text always passes AA */
  --v-zero: #0f7a57;
  --v-optional: #936200;
  --v-expected: #c0362b;
  --v-zero-soft: #e8f4ee;
  --v-optional-soft: #f6edd7;
  --v-expected-soft: #fbe7e4;
  --shadow: 0 1px 0 rgba(0,0,0,0.04), 0 10px 30px rgba(60,46,20,0.08);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Roboto Mono", monospace;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --maxw: 740px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120d;
    --paper: #1d1a13;
    --surface: #211e16;
    --ink: #f1ece0;
    --muted: #aaa08d;
    --line: #36301f;
    --rule: #4a4226;
    --accent: #ef7a63;
    --accent-ink: #1a0c08;
    --link: #f08a73;
    --v-zero: #36c08a;
    --v-optional: #d9a637;
    --v-expected: #f0726a;
    --v-zero-soft: #16271f;
    --v-optional-soft: #2a2410;
    --v-expected-soft: #2c1816;
    --shadow: 0 1px 0 rgba(0,0,0,0.3), 0 12px 30px rgba(0,0,0,0.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.62 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration: none; }

h1, h2, h3 { font-family: var(--serif); font-weight: 900; letter-spacing: -0.01em; line-height: 1.12; }
h1 { font-size: 2rem; margin: 0 0 .45em; }
h2 { font-size: 1.3rem; font-weight: 600; margin: 1.7em 0 .5em; }
h3 { font-size: 1.08rem; font-weight: 600; margin: 1.3em 0 .4em; }
p { margin: 0 0 1em; }

.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;
}

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- header / footer ---------- */
.site-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 14px; border-bottom: 2px dashed var(--rule);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-logo { width: 34px; height: 34px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--serif); font-weight: 900; font-size: 1.32rem; letter-spacing: -0.02em; }
.brand-name .q { color: var(--accent); }
.brand-tag { color: var(--muted); font-size: 0.78rem; margin-top: 3px; font-family: var(--sans); }

.site-footer {
  margin: 52px 0 60px; padding-top: 18px; border-top: 2px dashed var(--rule);
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: 0.92rem;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer .foot-note { flex-basis: 100%; color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

/* ---------- buttons (44px min touch target) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 11px 20px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; line-height: 1;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.is-copied { background: var(--v-zero); color: #fff; }
.btn-inline { display: inline-flex; margin: .5em 0; }

/* ---------- verdict icon (shape-coded, colour-blind safe) ---------- */
.vico { width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex: none; }

/* ---------- home hero (search-first) ---------- */
.hero { padding: 30px 0 6px; }
.hero h1 { font-size: 2.35rem; }
.hero .lead { color: var(--muted); font-size: 1.06rem; max-width: 34em; }

.tool-search { position: relative; margin: 20px 0 8px; }
.tool-search::before {
  content: "🔍"; position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  font-size: 1rem; opacity: .6; pointer-events: none;
}
.tool-search-input {
  width: 100%; min-height: 52px; padding: 14px 16px 14px 42px; font: inherit; color: var(--ink);
  background: var(--paper); border: 2px solid var(--rule); border-radius: 12px;
}
.tool-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(179,65,46,.18); }
.tool-search-empty { color: var(--muted); margin: 8px 2px; }

.popular { margin: 16px 0 8px; }
.popular-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-family: var(--sans); font-weight: 700; }
.popular-row { display: flex; flex-wrap: wrap; gap: 8px; }
.popular-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 14px;
  background: var(--paper); border: 2px solid var(--line); border-radius: 999px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem;
}
.popular-chip:hover { border-color: var(--accent); }
.popular-chip .pe { font-size: 1.15rem; }

/* ---------- verdict grid ---------- */
.vgroup { margin: 24px 0; }
.vgroup-h { display: flex; align-items: center; gap: 9px; font-size: 1.12rem; font-weight: 600; margin: 0 0 12px; }
.vgroup-h.v-zero { color: var(--v-zero); }
.vgroup-h.v-optional { color: var(--v-optional); }
.vgroup-h.v-expected { color: var(--v-expected); }

.sit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 560px) { .sit-list { grid-template-columns: 1fr 1fr; } }

.sit {
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 13px 14px; background: var(--paper); border: 1.5px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .08s ease, border-color .08s ease;
}
.sit:hover { transform: translateY(-1px); border-color: var(--accent); }
.sit:active { transform: translateY(0); }
.sit-ico { width: 42px; height: 42px; flex: none; border-radius: 11px; display: grid; place-items: center; }
.sit-ico .ic { width: 23px; height: 23px; }
.sit-ico.v-zero { background: var(--v-zero-soft); color: var(--v-zero); }
.sit-ico.v-optional { background: var(--v-optional-soft); color: var(--v-optional); }
.sit-ico.v-expected { background: var(--v-expected-soft); color: var(--v-expected); }
.pe { display: inline-flex; color: var(--accent); }
.pe .ic { width: 19px; height: 19px; }
.ric { display: inline-flex; color: var(--muted); }
.ric .ic { width: 17px; height: 17px; }
.sit-name { flex: 1; font-weight: 600; }
.sit-tag {
  display: inline-flex; align-items: center; gap: 5px; color: #fff;
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.sit-tag.v-zero { background: var(--v-zero); }
.sit-tag.v-optional { background: var(--v-optional); }
.sit-tag.v-expected { background: var(--v-expected); }

/* ---------- the verdict card = a permission slip / receipt ---------- */
body.tool-open { overflow: hidden; }
.tool-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center;
  background: rgba(20,12,4,.5);
}
/* Author display:grid above outranks the UA [hidden]{display:none}, so hidden must be explicit
   or the overlay never closes. (This was THE close bug.) */
.tool-overlay[hidden] { display: none; }
@media (min-width: 560px) { .tool-overlay { place-items: center; padding: 20px; } }
.tool-card {
  position: relative; width: 100%; max-width: 440px; background: var(--paper);
  padding: 22px 22px 24px; box-shadow: var(--shadow);
  border-radius: 18px 18px 0 0;
  /* torn-receipt top edge */
  border-top: 4px solid var(--ink);
  animation: rise .16s ease-out;
}
@media (min-width: 560px) { .tool-card { border-radius: 4px; } }
@keyframes rise { from { transform: translateY(16px); opacity: .4; } to { transform: none; opacity: 1; } }
.tool-grab { width: 40px; height: 4px; border-radius: 99px; background: var(--rule); margin: -8px auto 14px; }
@media (min-width: 560px) { .tool-grab { display: none; } }
.tool-close {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 1.7rem; line-height: 1; cursor: pointer;
}
.tool-close:hover { background: var(--line); }
.tool-head { display: flex; align-items: center; gap: 12px; padding-right: 36px; }
.tool-ico { width: 52px; height: 52px; flex: none; border-radius: 13px; display: grid; place-items: center; }
.tool-ico .ic { width: 28px; height: 28px; }
.tool-ico.v-zero { background: var(--v-zero-soft); color: var(--v-zero); }
.tool-ico.v-optional { background: var(--v-optional-soft); color: var(--v-optional); }
.tool-ico.v-expected { background: var(--v-expected-soft); color: var(--v-expected); }
.tool-name { margin: 0; font-size: 1.3rem; font-family: var(--serif); font-weight: 900; }

/* rubber-stamp verdict */
.stamp {
  display: inline-flex; align-items: center; gap: 8px; margin: 16px 0 4px;
  font-weight: 800; font-size: 1.06rem; color: #fff; padding: 9px 14px; border-radius: 8px;
  letter-spacing: .01em;
}
.stamp.v-zero { background: var(--v-zero); }
.stamp.v-optional { background: var(--v-optional); }
.stamp.v-expected { background: var(--v-expected); }

.tool-range, .verdict-range { font-family: var(--mono); color: var(--ink); }
.tool-range .rh, .verdict-range .rh { font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tool-range strong, .verdict-range strong { font-weight: 700; font-size: 1.05rem; }
.tool-range { margin: 8px 0 12px; }
.tool-short { margin: 0 0 18px; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- article / situation + static pages ---------- */
.article { padding: 26px 0 8px; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.verdict-hero {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 20px; box-shadow: var(--shadow);
  border-top: 4px dashed var(--rule);
}
.verdict-hero .stamp { margin-top: 0; }
.verdict-hero .verdict-range { display: block; margin-top: 10px; }

.when-add {
  border-left: 4px solid var(--accent); background: var(--paper); border-radius: 0 10px 10px 0;
  padding: 12px 16px; margin: 14px 0 20px;
}
.when-add h2 { margin-top: 0; font-size: 1.02rem; }

.faq { margin: 22px 0; }
.faq details {
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper);
  padding: 2px 16px; margin: 8px 0;
}
.faq summary { font-weight: 700; cursor: pointer; padding: 12px 0; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--muted); font-weight: 400; font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details[open] summary { border-bottom: 1px solid var(--line); }
.faq p { padding: 10px 0; margin: 0; }

.example { font-family: var(--mono); background: var(--v-zero-soft); border-radius: 8px; padding: 12px 14px; margin: 14px 0; font-size: .95rem; }
@media (prefers-color-scheme: dark) { .example { background: var(--surface); } }

.related { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 20px; }
.related a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 13px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 999px;
  text-decoration: none; color: var(--ink); font-size: .92rem;
}
.related a:hover { border-color: var(--accent); }

.src { font-size: .88rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 22px; }
.src a { color: var(--muted); }
.disclaimer { font-size: .82rem; color: var(--muted); font-style: italic; }
.share-row { margin: 16px 0; }
.byline { font-size: .85rem; color: var(--muted); margin: -6px 0 16px; }
.byline a { color: var(--muted); }

/* tipping chart table */
.tip-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .95rem; }
.tip-table th, .tip-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tip-table th { font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tip-table td.range { font-family: var(--mono); white-space: nowrap; }
.tip-table .tag { display: inline-flex; align-items: center; gap: 5px; color: #fff; font-size: .68rem; font-weight: 800; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.tip-table .tag.v-zero { background: var(--v-zero); }
.tip-table .tag.v-optional { background: var(--v-optional); }
.tip-table .tag.v-expected { background: var(--v-expected); }

/* sources list */
.source-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; }
.source-list li { padding: 14px 16px; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); }
.source-list .pub { font-weight: 700; }
.source-list .meta { color: var(--muted); font-size: .9rem; }

/* ad slot */
.ad-slot { margin: 28px 0; min-height: 90px; text-align: center; }
.ad-slot ins { display: block; }

/* consent banner */
.ton-consent {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 80; margin: 0 auto;
  max-width: 640px; background: var(--surface); border: 2px solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px 18px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
}
.ton-consent p { margin: 0; flex: 1 1 240px; font-size: .92rem; }
.ton-consent-actions { display: flex; gap: 8px; margin-left: auto; }
.ton-consent .btn { min-height: 40px; padding: 9px 16px; }

/* dark mode: verdict fills become light pastels, so flip pill text to dark ink for AA contrast
   (white-on-pastel fails; dark ink on the dark-mode --v-* fills clears 5.8–7.5:1). currentColor
   carries the shape icon along with it. */
@media (prefers-color-scheme: dark) {
  .sit-tag, .stamp, .tip-table .tag, .btn.is-copied { color: #16130d; }
}

/* motion safety */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
