/* Plainsight
   A plum-ink band and warm ledger paper; a highlighter marks the answer, the way you'd
   mark the one figure that matters on a printout. Fraunces for headlines, IBM Plex Sans
   for reading and IBM Plex Mono for SQL. Same family as Jhola and QuoteRunner: dark band,
   big question, the input sitting on the band's edge. */

:root {
  --plum: #24193a;
  --plum-2: #3a2759;
  --paper: #f6f4ef;
  --card: #ffffff;
  --ink: #1f1830;
  --muted: #5f5870;
  --line: #e2ded6;
  --highlight: #e4f36b;
  --highlight-soft: #f5fbc9;
  --lilac: #d9cdf5;
  --bar: #5b3fa6;
  --bar-track: #ece8f6;
  --green: #22744a;
  --green-soft: #e3f1e8;
  --amber: #85580a;
  --amber-soft: #fbf0d6;
  --error: #a3302a;
  --error-bg: #fbeceb;
  --on-band: #f6f4ef;
  --on-band-muted: #cbc2df;
  --code-bg: #1d1530;
  --code-ink: #ece7f8;
  --focus: #5b3fa6;
  --display: "Fraunces", Georgia, serif;
  --text: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --wrap: 1120px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip; /* the tilted sheets must never cause sideways scrolling */
}

h1, h2, h3 { margin: 0; }
p { margin: 0; }
code { font: 0.9em var(--mono); background: var(--bar-track); padding: 1px 5px; border-radius: 4px; }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--bar);
    text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { text-decoration-thickness: 3px; }
.band a { text-decoration-color: var(--highlight); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.band :focus-visible { outline-color: var(--highlight); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

/* --- The plum band (header + hero) ------------------------------------------- */
.band {
  position: relative;
  isolation: isolate;
  color: var(--on-band);
  background:
    radial-gradient(ellipse 55% 70% at 90% 0%, rgba(228, 243, 107, 0.22), transparent 70%),
    radial-gradient(ellipse 50% 60% at 0% 100%, rgba(150, 120, 230, 0.28), transparent 70%),
    linear-gradient(165deg, var(--plum) 0%, var(--plum-2) 100%);
}
.band::after { /* a little grain, like Jhola's */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.18;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.band-inner { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0; }
.wordmark { font: 700 1.7rem/1 var(--display); letter-spacing: -0.01em; text-decoration: none; }
.wordmark span { background: linear-gradient(transparent 74%, var(--highlight) 74%, var(--highlight) 92%, transparent 92%);
                 padding: 0 1px; }
.toplinks { display: flex; gap: 24px; font-weight: 600; font-size: 0.95rem; }
.toplinks a { text-decoration-color: transparent; }
.toplinks a:hover, .toplinks a[aria-current="page"] { text-decoration-color: var(--highlight); }

.lede { color: var(--on-band-muted); font-size: 1.15rem; line-height: 1.65; max-width: 34em; }

/* Inner pages: a headline in the band */
.page-hero { padding: 40px 0 64px; }
.page-hero h1 { font: 700 clamp(2.6rem, 5.6vw, 4.4rem)/1 var(--display); letter-spacing: -0.02em;
                max-width: 14em; margin-bottom: 18px; text-wrap: balance; }

/* --- Home hero ------------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 48px;
  align-items: end;
  padding-top: 40px;
}
.hero h1 { font: 700 clamp(3rem, 6.6vw, 5.6rem)/0.95 var(--display); letter-spacing: -0.025em;
           margin-bottom: 24px; text-wrap: balance; }
.hero .lede { margin-bottom: 40px; }

/* The question box sits on the band's bottom edge, half in and half out. */
.ask {
  display: flex;
  gap: 8px;
  padding: 7px;
  margin-bottom: -33px;
  position: relative;
  z-index: 1;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 7px 7px 0 var(--highlight);
}
.ask input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 10px 12px;
  font: 1.1rem var(--text);
  color: var(--ink);
  background: transparent;
}
.ask input::placeholder { color: #7a7389; }
.ask input:focus-visible { outline: none; }
.ask:focus-within { outline: 3px solid var(--highlight); outline-offset: 4px; }
.ask button, .button {
  border: 0;
  border-radius: 9px;
  padding: 12px 26px;
  background: var(--plum);
  color: var(--on-band);
  font: 700 1rem var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.ask button:hover, .button:hover { background: var(--plum-2); }
button:disabled { opacity: 0.55; cursor: default; }

/* The stack of printouts: white over lilac over highlighter. */
.sheets { position: relative; margin: 0 0 -170px; justify-self: end; width: min(100%, 420px); z-index: 2; }
.sheet { position: absolute; inset: 0; border-radius: 6px; }
.sheet-back { background: var(--highlight); transform: translate(16px, 14px) rotate(4.5deg); }
.sheet-mid { background: var(--lilac); transform: translate(8px, 7px) rotate(2deg); }
.sheet-front {
  position: relative;
  background: var(--card);
  color: var(--ink);
  border-radius: 6px;
  padding: 22px 24px 28px;
  transform: rotate(-1.5deg);
  box-shadow: 0 26px 50px -18px rgba(18, 10, 36, 0.6);
}
.sheet-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase;
               letter-spacing: 0.06em; margin-top: 10px; }
.sheet-label:first-child { margin-top: 0; }
.sheet-quote { font: 600 1.15rem/1.35 var(--display); margin: 4px 0 4px; }
.sheet-sql { font: 0.74rem/1.55 var(--mono); background: var(--paper); border: 1px solid var(--line);
             border-radius: 6px; padding: 8px 10px; margin: 6px 0 2px; white-space: pre; overflow: hidden; }
.sheet-sql b { color: var(--bar); font-weight: 600; }
.sheet-answer { font: 700 2.6rem/1.1 var(--display); margin-top: 2px; }
.sheet-answer small { font: 500 0.9rem var(--text); color: var(--muted); }
mark { background: linear-gradient(transparent 12%, var(--highlight) 12%, var(--highlight) 88%, transparent 88%);
       color: inherit; padding: 0 4px; }
.stamp {
  position: absolute;
  right: -16px;
  bottom: -20px;
  transform: rotate(-10deg);
  font: 700 1.1rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(255, 255, 255, 0.92);
  border: 3px double var(--green);
  border-radius: 8px;
  padding: 8px 14px 7px;
}

/* --- Below the hero ---------------------------------------------------------------- */
.below-inner { max-width: var(--wrap); margin: 0 auto; padding: 60px 24px 80px; }
.below .chips, .below .proof, .below .left { max-width: 640px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 16px;
  font: 500 0.93rem var(--text);
  cursor: pointer;
  text-align: left;
}
.chip:hover { border-color: var(--bar); }
.left { margin-top: 16px; color: var(--muted); font-size: 0.88rem; }
.proof { margin-top: 10px; color: var(--muted); font-size: 0.98rem; }
.proof a { color: var(--ink); font-weight: 600; }

/* After the first question, the band shrinks to the bar and the box. */
.asked .hero { grid-template-columns: 1fr; padding-top: 4px; }
.asked .hero h1, .asked .hero .lede, .asked .sheets { display: none; }
.asked .ask { max-width: 760px; }
.asked .below-inner { padding-top: 56px; }
.asked .how, .asked .proof { display: none; }

/* --- Answers ------------------------------------------------------------------------- */
.results { display: grid; gap: 22px; margin-top: 32px; }
.results:empty { display: none; }

.result { background: var(--card); border: 1.5px solid var(--ink); border-radius: 16px; overflow: hidden; }
.result.latest { box-shadow: 6px 6px 0 var(--lilac); }
.result-head { padding: 18px 22px 0; display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.result-q { font: 600 1.3rem/1.3 var(--display); letter-spacing: -0.01em; }
.result-meta { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.result-body { padding: 14px 22px 20px; }

.value-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.value { font: 700 clamp(2.4rem, 6vw, 3.6rem)/1.1 var(--display); letter-spacing: -0.02em; margin-top: 2px;
         overflow-wrap: anywhere; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; }
.notice strong { display: block; }
.notice.refused { background: var(--amber-soft); color: var(--amber); }
.notice.refused p { color: var(--ink); font-size: 0.93rem; margin-top: 2px; }
.notice.failed { background: var(--error-bg); color: var(--error); }
.notice.failed p { color: var(--ink); font-size: 0.93rem; margin-top: 2px; overflow-wrap: anywhere; }
.notice .icon { flex: none; width: 22px; height: 22px; margin-top: 2px; }

/* Bars, in the order the query returned them */
/* One grid for the whole list, so every bar starts and ends in the same place. */
.bars { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px 12px;
        grid-template-columns: minmax(120px, 30%) minmax(0, 1fr) auto; }
.bars li { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; font-size: 0.92rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 20px; background: var(--bar-track); border-radius: 0 5px 5px 0; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar); border-radius: 0 5px 5px 0; min-width: 2px; }
.bar-value { text-align: right; color: var(--muted); }
.result .bars li:first-child .bar-fill { background: linear-gradient(90deg, var(--bar), #7b5fd0); }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--card); }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; position: sticky; top: 0; background: var(--card); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.null { color: var(--muted); font-style: italic; }
.caption { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }

/* The SQL, always visible: it's the receipt for the answer. */
.sql-box { border-top: 1px solid var(--line); background: var(--paper); padding: 14px 22px 18px; }
.sql-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.sql-head p, .sql-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase;
                          letter-spacing: 0.06em; }
.copy { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 7px;
        padding: 3px 10px; font: 500 0.82rem var(--text); cursor: pointer; }
.copy:hover { border-color: var(--bar); }
pre.sql {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-ink);
  font: 0.86rem/1.6 var(--mono);
  padding: 12px 14px;
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.sql .kw { color: var(--highlight); font-weight: 500; }
.retried { font-size: 0.85rem; color: var(--amber); margin-top: 8px; }

.result.pending .result-body { color: var(--muted); }
.thinking { display: flex; align-items: center; gap: 10px; }
.thinking::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--bar);
                    animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.8); } }

.banner { padding: 12px 16px; border-radius: 12px; background: var(--error-bg); color: var(--error); font-weight: 500; }

/* --- How it works (home, before the first question) --------------------------------- */
.how { margin-top: 72px; }
.how h2, .page h2 { font: 700 clamp(1.7rem, 3.2vw, 2.3rem)/1.1 var(--display); letter-spacing: -0.015em;
                    margin-bottom: 18px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid;
         grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.steps li { counter-increment: step; background: var(--card); border: 1.5px solid var(--ink); border-radius: 14px;
            padding: 18px 20px 20px; }
.steps li::before {
  content: counter(step);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--plum);
  color: var(--highlight);
  font: 700 1.1rem/1 var(--display);
  margin-bottom: 12px;
}
.steps h3 { font-size: 1.02rem; margin-bottom: 4px; }
.steps p { color: var(--muted); font-size: 0.93rem; }

/* --- Scorecard ---------------------------------------------------------------------- */
.page { max-width: var(--wrap); margin: 0 auto; padding: 44px 24px 72px; }
.page section + section { margin-top: 60px; }
.meta { color: var(--muted); font-size: 0.95rem; max-width: 60em; margin-bottom: 18px; }
.meta strong { color: var(--ink); }
.section-lede { color: var(--muted); max-width: 42em; margin-bottom: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1.5px solid var(--ink); border-radius: 14px; padding: 14px 16px;
        display: flex; flex-direction: column; gap: 2px; font-size: 0.88rem; color: var(--muted); }
.card .big { font: 700 2.4rem/1.1 var(--display); color: var(--ink); letter-spacing: -0.02em; }
.card.good { box-shadow: 5px 5px 0 var(--highlight); }

.page .bars { max-width: 820px; }
.page .bars { grid-template-columns: minmax(150px, 34%) minmax(0, 1fr) auto; }
.page .bars li { font-size: 0.95rem; }
.page .bar-value { color: var(--ink); font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tabs a { text-decoration: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
          padding: 6px 14px; font-size: 0.9rem; font-weight: 500; }
.tabs a:hover { border-color: var(--bar); }
.tabs a[aria-current="true"] { background: var(--plum); border-color: var(--plum); color: var(--on-band); }
.tabs .count { display: inline-block; min-width: 1.6em; text-align: center; font-size: 0.78rem; font-weight: 700;
               border-radius: 999px; background: var(--bar-track); color: var(--ink); padding: 0 6px; margin-left: 4px; }

.failures { display: grid; gap: 10px; }
.failure { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.failure summary { cursor: pointer; padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px;
                   align-items: baseline; list-style: none; }
.failure summary::-webkit-details-marker { display: none; }
.failure summary .q::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--bar); transition: transform 0.15s; }
.failure[open] summary .q::before { transform: rotate(90deg); }
.failure[open] summary { border-bottom: 1px solid var(--line); }
.failure .why { padding: 12px 16px 0; font-size: 0.93rem; }
.failure > .small { padding: 0 16px 14px; }
.two-sql { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; padding: 12px 16px 16px; }
.two-sql .sql-label { margin-bottom: 6px; }
.two-sql pre.sql { font-size: 0.8rem; }
.tag { flex: none; font-size: 0.75rem; font-weight: 600; padding: 1px 10px; border-radius: 999px;
       background: var(--bar-track); color: var(--ink); }
.tag.hard { background: var(--amber-soft); color: var(--amber); }
.tag.unanswerable { background: var(--error-bg); color: var(--error); }

/* --- Footer ------------------------------------------------------------------------- */
.footer-inner { max-width: var(--wrap); margin: 0 auto; padding: 0 24px 48px; }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap;
              padding-top: 28px; border-top: 1px solid var(--line); }
.footer-row p { font-size: 1.05rem; }
.footer-row a { font-weight: 600; }
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; font-size: 0.95rem; }
.disclaimer { margin-top: 18px; color: var(--muted); font-size: 0.88rem; max-width: 62em; }

/* --- Smaller screens --------------------------------------------------------------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 0; padding-top: 20px; }
  .ask { margin-bottom: 0; }
  .sheets { justify-self: center; margin: 56px 0 -60px; width: min(88%, 400px); }
  .below-inner { padding-top: 96px; }
  .asked .ask { margin-bottom: -33px; }
  .two-sql { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .band-inner, .below-inner, .page, .footer-inner { padding-left: 16px; padding-right: 16px; }
  .toplinks { gap: 16px; font-size: 0.9rem; }
  .wordmark { font-size: 1.45rem; }
  .ask { flex-wrap: wrap; }
  .ask button { width: 100%; }
  .asked .ask { margin-bottom: -60px; }
  .asked .below-inner { padding-top: 84px; }
  .stamp { right: -6px; font-size: 0.95rem; }
  .sheet-sql { font-size: 0.66rem; }
  .result-head { flex-direction: column; gap: 2px; padding: 16px 16px 0; }
  .result-body { padding: 12px 16px 18px; }
  .sql-box { padding: 12px 16px 16px; }
  .bars, .page .bars { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .bars li + li { margin-top: 6px; }
  .bars .bar-label { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
