
@font-face { font-family: "Inter"; src: url("fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #1d3823;
  --panel: #101c14;
  --panel-2: #172a1d;
  --cream: #efe3c1;
  --cream-dim: #cfc4a4;
  --sage: #94a38f;
  --ink-soft: #4a5a43;
  --line: rgba(239, 227, 193, 0.12);
  --line-strong: rgba(239, 227, 193, 0.22);
  --serif: "Newsreader", "Tiempos Headline", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;

}
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 72% 18%, rgba(239,227,193,0.08), transparent 70%),
    radial-gradient(38% 32% at 18% 72%, rgba(255,255,255,0.045), transparent 70%),
    radial-gradient(60% 50% at 0% 40%, rgba(0,0,0,0.22), transparent 70%);
  animation: drift 30s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes drift { to { transform: translate3d(-4%, 3%, 0) scale(1.06); } }

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
}

/* ---------- entrance ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes line-up { from { transform: translateY(105%); } to { transform: none; } }
.enter-load { animation: rise .7s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand span { font: 400 30px/1 var(--serif); letter-spacing: 0.02em; }
.byline {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px;
  color: var(--cream); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: rgba(0,0,0,0.22); touch-action: manipulation;
  transition: background-color .2s ease, border-color .2s ease, transform .16s ease-out;
}
.byline svg { width: 14px; height: 14px; fill: currentColor; }
.byline:active { transform: scale(0.97); }
.byline:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }

h1 {
  font: 400 clamp(34px, 8.5vw, 60px)/1.04 var(--serif);
  letter-spacing: -0.025em;
  margin: 0 0 4px;
}
h1 .ln { display: block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.12em; }
h1 .ln > span { display: block; animation: line-up .9s var(--ease-out) both; animation-delay: calc(100ms + var(--i, 0) * 90ms); }

/* ---------- layout: input left, result right ---------- */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "intro" "input" "result" "scen";
  gap: 12px;
  margin-bottom: 12px;
}
.g-intro { grid-area: intro; }
.g-input { grid-area: input; }
.g-result { grid-area: result; }
.g-scen { grid-area: scen; }

.card {
  position: relative;
  background:
    radial-gradient(rgba(239,227,193,0.07) 1px, transparent 1.2px) 0 0 / 14px 14px,
    linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 1px 0 rgba(239,227,193,0.06) inset, 0 20px 40px -24px rgba(0,0,0,0.6);
}
.card h2 {
  font: 500 12px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--sage);
  margin: 0 0 14px;
}

/* ---------- input ---------- */
label, .lbl { display: block; font-size: 13px; color: var(--sage); margin-bottom: 6px; }
input {
  width: 100%;
  font: 500 16px var(--sans); /* 16px stops iOS zoom */
  color: var(--cream);
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input:focus { outline: none; border-color: var(--cream); background: rgba(0,0,0,0.4); box-shadow: 0 0 0 4px rgba(239,227,193,0.1); }
.g-input input {
  font: 400 clamp(34px, 9vw, 48px)/1.1 var(--serif);
  letter-spacing: -0.02em;
  padding: 10px 16px;
  border-radius: 16px;
}
.check {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; min-height: 48px; padding: 0 16px;
  color: var(--cream); font-weight: 500; font-size: 15px; text-decoration: none;
  background: rgba(239,227,193,0.1); border: 1px solid rgba(239,227,193,0.35); border-radius: 14px;
  touch-action: manipulation;
  transition: background-color .2s ease, border-color .2s ease, transform .16s ease-out;
}
.check svg { width: 16px; height: 16px; flex: none; transition: transform .2s var(--ease-out); }
.check:active { transform: scale(0.98); }
.check:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }
.tiny { font-size: 12px; color: var(--sage); opacity: .85; margin-top: 8px; }

/* ---------- chips ---------- */
.field + .field { margin-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  font: 500 13px var(--sans);
  color: var(--cream-dim);
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  min-height: 38px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .16s ease-out;
}
.chips button:active { transform: scale(0.96); }
.chips button[aria-pressed="true"] { background: var(--cream); color: var(--bg); border-color: var(--cream); }
.chips button:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }

/* ---------- result: the big number ---------- */
.result {
  background: radial-gradient(rgba(29,56,35,0.09) 1px, transparent 1.3px) 0 0 / 14px 14px, var(--cream);
  color: var(--bg);
  border-radius: 24px;
  padding: 20px 18px;
  box-shadow: 0 24px 48px -28px rgba(0,0,0,0.7);
}
.res-label { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); }
.res-value {
  font: 400 clamp(64px, 19vw, 120px)/0.95 var(--serif);
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin: 12px 0 10px;
}
.res-sub { font-size: 15px; color: var(--ink-soft); }
.res-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(29,56,35,0.2);
}
.res-stats .v { font: 400 22px/1.1 var(--serif); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-stats .k { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.pos { color: #14653c; }
.neg { color: #8f2b25; }

/* ---------- tweet facts ---------- */
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
.facts .v { font: 400 24px/1.1 var(--serif); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.facts .k { font-size: 12px; color: var(--sage); margin-top: 2px; }
details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-size: 13px; color: var(--sage); list-style: none; min-height: 32px; display: flex; align-items: center; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; margin-left: 8px; transition: transform .2s var(--ease-out); }
details[open] summary::after { transform: rotate(45deg); }
.edit { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }

/* ---------- profitability map ---------- */
.map-card { container-type: inline-size; container-name: map; }
.map-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.map-head h2 { margin: 0; }
.seg { display: inline-flex; background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button {
  font: 500 13px var(--sans); color: var(--sage); background: transparent; border: 0; border-radius: 999px;
  padding: 0 14px; min-height: 34px; cursor: pointer; touch-action: manipulation;
  transition: background-color .2s ease, color .2s ease, transform .16s ease-out;
}
.seg button:active { transform: scale(0.97); }
.seg button[aria-pressed="true"] { background: var(--cream); color: var(--bg); }
.seg button:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }
.heat { display: grid; grid-template-columns: 34px repeat(5, 1fr); gap: 4px; font-variant-numeric: tabular-nums; }
.hh { font-size: 11px; color: var(--sage); display: flex; align-items: center; justify-content: center; min-height: 24px; }
.hc {
  font: 500 12px var(--sans);
  color: var(--cream);
  text-align: center;
  padding: 12px 0;
  border: 0;
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .3s ease, transform .16s ease-out, box-shadow .2s ease;
}
.hc:active { transform: scale(0.95); }
.hc[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--cream); }
.hc:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }
.opt { display: none !important; }
.heat.enter .hc { animation: rise .5s var(--ease-out) both; animation-delay: calc(var(--d, 0ms) + 100ms); }
@container map (min-width: 480px) {
  .heat { grid-template-columns: 56px repeat(7, 1fr); gap: 6px; }
  .hc.opt { display: block !important; }
  .hh.opt { display: flex !important; }
  .hc { font-size: 13px; padding: 14px 0; }
  .hh { font-size: 12px; }
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--sage); margin-top: 14px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
.legend .g { background: rgba(47,158,107,0.7); }
.legend .r { background: rgba(179,74,68,0.75); }

.note { font-size: 12px; color: var(--sage); border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; }

/* ---------- reveal on scroll (map only) ---------- */
.js .reveal { opacity: 0; transform: translateY(16px); }
.js .reveal.in { opacity: 1; transform: none; transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }

/* ---------- >= 640px ---------- */
@media (min-width: 640px) {
  .wrap { padding: 36px 24px 56px; }
  .topbar { margin-bottom: 28px; }
  .card { padding: 22px; border-radius: 22px; }
  .result { padding: 28px 26px; }
  .res-stats .v { font-size: 26px; }
  .facts { grid-template-columns: repeat(4, 1fr); }
  .edit { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- >= 900px: left inputs, right result ---------- */
@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-areas: "intro result" "input result" "scen result";
    grid-template-rows: auto auto 1fr;
    gap: 16px 20px;
  }
  .g-result { align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
  .res-value { font-size: clamp(96px, 11vw, 148px); }
}

@media (hover: hover) and (pointer: fine) {
  .byline:hover { background: rgba(239,227,193,0.12); border-color: var(--cream); }
  .check:hover { background: rgba(239,227,193,0.18); border-color: var(--cream); }
  .check:hover svg { transform: translate(2px, -2px); }
  .chips button:not([aria-pressed="true"]):hover { border-color: var(--line-strong); color: var(--cream); }
  .hc:hover { transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  @keyframes rise { from { opacity: 0; } to { opacity: 1; } }
  @keyframes line-up { from { opacity: 0; } to { opacity: 1; } }
  .js .reveal { transform: none; }
  .hc:hover, .hc:active { transform: none; }
}
