/* ───────────────────────────────────────────────────────────────────
   Content Radar — "Aurora Glass" UI (Gemini-inspired, light theme)
   Follows GEMINI_DESIGN_SYSTEM.md. Report output (worker/render.js)
   is intentionally NOT affected by this file.
   ─────────────────────────────────────────────────────────────────── */
:root {
  /* type */
  --font-sans: "Google Sans Flex", "Google Sans", "Inter", -apple-system,
               BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display-weight: 320;            /* the signature light big-text weight */

  /* light canvas */
  --bg:          #FDFCFC;           /* warm off-white, never pure #FFF */
  --surface:     #FFFFFF;           /* cards / inputs */
  --surface-2:   #F2F0F0;           /* selected / hover fill */
  --text:        #1F1F1F;
  --text-2:      #444746;
  --text-3:      #80868B;           /* captions / volumes */
  --line:        #ECEAE6;           /* whisper hairline */

  /* the signature accent: YEA orange — deep orange → warm amber */
  --gem-spark:   linear-gradient(135deg, #E2613B 0%, #E89A14 100%);
  --gem-spark-3: linear-gradient(135deg, #D9542B 0%, #E2613B 50%, #E89A14 100%);
  --accent:      #E08A1E;           /* warm amber-orange — small active accents */
  --accent-blue: #E2613B;           /* deep YEA orange — focus / links / active */
  --accent-soft: rgba(226,97,59,0.14);
  /* YEA company wordmark spectrum (logo only) */
  --yea-spectrum: linear-gradient(90deg, #E2613B, #E89A14, #5BA62E, #12A2B5, #3F77CC, #8B5EC2);
  --rose:        #C5495B;
  --warm:        #C97B3A;

  /* aurora glow (orange→amber family, soft) */
  --aurora-edge: #FFD8A6;           /* pale tint of the amber end */
  --aurora-blur: 120px;

  /* shape */
  --r-card: 16px; --r-field: 16px; --r-input: 28px; --r-pill: 9999px;

  /* elevation (whisper-soft — depth comes from the glow, not shadow) */
  --shadow-input: 0 2px 8px -2px rgba(60,32,16,0.14);
  --shadow-pop:   0 2px 6px rgba(60,32,16,0.16), 0 1px 18px rgba(60,32,16,0.10);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);

  /* spacing */
  --s-1:4px; --s-2:8px; --s-3:12px; --s-4:16px; --s-5:20px; --s-6:24px; --s-8:32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Aurora glow ──────────────────────────────────────────────────── */
/* Layers fade to transparent so the warm-white canvas shows at the edges
   and the blue reads as a soft bloom behind the input — not a flat wash. */
.aurora-stage { position: relative; isolation: isolate; }
.aurora-stage::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: 50%; top: 38%; width: 116%; height: 114%;
  transform: translate(-50%, -45%);
  background:
    radial-gradient(42% 34% at 50% 56%, rgba(226,97,59,0.50) 0%, rgba(226,97,59,0) 64%),
    radial-gradient(44% 36% at 29% 38%, rgba(217,84,43,0.44) 0%, rgba(217,84,43,0) 66%),
    radial-gradient(46% 36% at 74% 44%, rgba(232,154,20,0.54) 0%, rgba(232,154,20,0) 66%);
  filter: blur(var(--aurora-blur));
  animation: aurora-grow 1s var(--ease-emphasized) both;
}
@keyframes aurora-grow {
  0%   { opacity: 0; transform: translate(-50%, -45%) scale(0.4); }
  100% { opacity: 1; transform: translate(-50%, -45%) scale(1); }
}
@media (max-width: 768px) {
  .aurora-stage::before { animation: aurora-fade 1s var(--ease-emphasized) both; }
  @keyframes aurora-fade { from { opacity: 0; } to { opacity: 1; } }
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: rgba(253,252,252,0.72);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 5;
}
.brand {
  font-weight: 500; font-size: 15px; color: var(--text);
  display: inline-flex; align-items: baseline; gap: 6px; letter-spacing: -0.01em;
}
.brand-name {
  font-weight: 600;
  background: var(--yea-spectrum); -webkit-background-clip: text;
  background-clip: text; color: transparent;
}
.brand-by { color: var(--text-3); font-weight: 400; }
.brand small { color: var(--text-3); font-weight: 400; margin-left: 2px; }

/* ── Page ─────────────────────────────────────────────────────────── */
.page { max-width: 1040px; width: 100%; margin: 0 auto; padding: 8px 22px 48px; flex: 1 0 auto; }

/* ── Footer ───────────────────────────────────────────────────────── */
.site-footer {
  flex-shrink: 0; text-align: center;
  padding: 30px 16px 40px; font-size: 13px; color: var(--text-3); letter-spacing: 0.01em;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.footer-built-row {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 500; color: var(--text-2);
}
.footer-logo { height: 22px; width: auto; display: inline-block; }
.footer-lines { display: flex; flex-direction: column; gap: 2px; line-height: 1.55; }

/* ── Hero (transparent — the glow shows through) ──────────────────── */
.intro {
  text-align: center;
  padding: 64px 16px 36px;
  margin-bottom: 12px;
}
.intro h1 {
  font-weight: var(--display-weight);
  font-size: clamp(24px, 4.4vw, 38px);
  line-height: 1.2; letter-spacing: -0.015em;
  margin: 0 auto 14px; white-space: nowrap;   /* one line on desktop/tablet */
  background: var(--gem-spark);
  background-size: 220% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: gradient-flow 9s linear infinite;
}
@keyframes gradient-flow {
  0% { background-position: 0% center; } 100% { background-position: 220% center; }
}
.intro > p {
  color: var(--text-2); font-size: 15px; max-width: 600px;
  margin: 0 auto 28px;
}

/* ── Composer (form) ──────────────────────────────────────────────── */
#composer { max-width: 720px; margin: 0 auto; text-align: left; }
.row { display: flex; gap: 10px; margin-bottom: 10px; }
#composer input, #composer select {
  flex: 1; width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  font-size: 16px; font-family: inherit; color: var(--text);   /* 16px = no iOS focus-zoom */
  background: var(--surface);
  box-shadow: var(--shadow-input);
  transition: border-color .18s, box-shadow .18s;
}
#composer input::placeholder { color: var(--text-3); }
#composer input:focus, #composer select:focus {
  outline: none; border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-input);
}
#composer select { cursor: pointer; }

.advanced { margin: 6px 0 4px; font-size: 13.5px; color: var(--text-2); }
.advanced summary {
  cursor: pointer; padding: 8px 4px; list-style: none;
  color: var(--text-2); border-radius: var(--r-pill);
  width: fit-content;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "＋ "; color: var(--accent); font-weight: 600; }
.advanced[open] summary::before { content: "－ "; }
.advanced summary:hover { color: var(--accent-blue); }
.advanced .grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
#fetchBtn, #genBtn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gem-spark); color: #fff; border: none;
  padding: 0 30px; height: 50px; border-radius: var(--r-pill);
  font-size: 15px; font-weight: 500; font-family: inherit; cursor: pointer;
  margin-top: 14px; box-shadow: var(--shadow-input);
  transition: filter .18s, transform .12s, box-shadow .18s;
}
#fetchBtn { display: flex; width: fit-content; margin: 18px auto 0; }   /* center under the form */
#fetchBtn:hover, #genBtn:hover { filter: brightness(1.06); box-shadow: var(--shadow-pop); }
#fetchBtn:active, #genBtn:active { transform: translateY(1px); }
#fetchBtn:disabled, #genBtn:disabled {
  opacity: 0.5; cursor: progress; filter: none; box-shadow: none;
}

.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  padding: 0 16px; height: 38px; border-radius: var(--r-pill);
  font-size: 13.5px; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .16s, color .16s, border-color .16s;
}
.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--surface-2); }
.ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.ghost:disabled:hover { background: transparent; color: var(--text-2); border-color: var(--line); }
.ghost.wide { display: flex; width: 100%; justify-content: center; height: 46px; margin-top: 6px; }

/* Round-2 button: stays ghost-white while locked, turns solid orange (like the
   primary Fetch button) the moment round 1 finishes and it becomes clickable —
   so it's obvious the next action is available. */
#expandBtn:not(:disabled) {
  background: var(--gem-spark); color: #fff; font-weight: 500;
  border-color: transparent; box-shadow: var(--shadow-input);
  /* snap color/border instantly (the .ghost color transition mis-settles on
     the orange fill); the pop comes from the expand-ready keyframe instead */
  transition: filter .18s, transform .12s, box-shadow .18s;
  animation: expand-ready .45s var(--ease-emphasized) both;
}
#expandBtn:not(:disabled):hover {
  background: var(--gem-spark); color: #fff; border-color: transparent;
  filter: brightness(1.06); box-shadow: var(--shadow-pop);
}
#expandBtn:not(:disabled):active { transform: translateY(1px); }
@keyframes expand-ready { from { transform: scale(0.985); opacity: 0.55; } to { transform: scale(1); opacity: 1; } }

/* more specific than `.intro > p` so the top gap below the button actually applies */
.intro > p.round-note { font-size: 13px; color: var(--text-3); text-align: center; margin: 40px auto 18px; max-width: 620px; }
.round-note b { color: var(--text-2); font-weight: 500; }

/* ── Cards (preview panel) ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 26px; margin-bottom: 22px;
}
.hidden { display: none; }

.fetch-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.fetch-head h2 { font-weight: 400; font-size: 22px; letter-spacing: -0.01em; margin: 0 0 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions #genBtn { margin-top: 0; }

/* ── Chips ────────────────────────────────────────────────────────── */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 6px 13px; border-radius: var(--r-pill); font-weight: 500;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); display: inline-flex; align-items: center; gap: 7px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.chip.loading .dot { background: var(--warm); animation: pulse 1s infinite; }
.chip.ready { background: var(--accent-soft); color: var(--accent-blue); border-color: transparent; }
.chip.ready .dot { background: var(--accent); }
.chip.failed { color: var(--rose); }
.chip.failed .dot { background: var(--rose); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ── Provider blocks ─────────────────────────────────────────────── */
.prov-block {
  border: 1px solid var(--line); border-radius: var(--r-card);
  margin-bottom: 16px; overflow: hidden; background: var(--surface);
}
.prov-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; background: var(--surface-2);
  font-weight: 500; font-size: 14.5px;
}
.prov-head .count { color: var(--text-3); font-weight: 400; font-size: 12.5px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 16px 2px; }
.tab {
  font-size: 12.5px; padding: 7px 14px; border-radius: var(--r-pill); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

.kw-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kw-table td { padding: 9px 18px; border-top: 1px solid var(--line); color: var(--text-2); }
.kw-table tr:first-child td { border-top: none; }
.kw-table td.vol { text-align: right; color: var(--text-3); white-space: nowrap; width: 90px; }
.kw-wrap { max-height: 360px; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }

.ai-list { padding: 4px 0; }
.ai-list .ai-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--text-2);
}
.ai-list .ai-row:first-child { border-top: none; }
.ai-list .tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); white-space: nowrap;
}

.note { font-size: 13.5px; color: var(--text-3); padding: 12px 2px; }
.err { color: var(--rose); }

/* ── Report result ────────────────────────────────────────────────── */
#reportResult { margin-top: 16px; }
.report-link { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.report-link a, .copy {
  background: var(--gem-spark); color: #fff; text-decoration: none;
  padding: 0 18px; height: 42px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 500;
  border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow-input); transition: filter .18s;
}
.report-link a:hover, .copy:hover { filter: brightness(1.06); }
.copy { background: var(--surface); color: var(--accent-blue); border: 1px solid var(--line); box-shadow: none; }
.statusline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: s 0.8s linear infinite;
}
@keyframes s { to { transform: rotate(360deg); } }

/* ── Settings dialog ──────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 26px; box-shadow: var(--shadow-pop); color: var(--text);
}
dialog::backdrop { background: rgba(60,32,16,0.32); backdrop-filter: blur(2px); }
.settings { display: flex; flex-direction: column; gap: 14px; min-width: 380px; }
.settings h3 { margin: 0; font-weight: 500; font-size: 18px; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.settings input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-field);
  font-family: inherit; font-size: 16px; background: var(--surface);
}
.settings input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-soft); }
.settings menu { display: flex; gap: 10px; justify-content: flex-end; padding: 0; margin: 8px 0 0; }
.settings menu button {
  padding: 0 18px; height: 42px; border-radius: var(--r-pill); border: none; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 500; background: var(--gem-spark); color: #fff;
}
.settings menu .ghost { background: transparent; color: var(--text-2); border: 1px solid var(--line); }

/* ── Auth gate ────────────────────────────────────────────────────── */
.auth-gate {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.auth-box {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 34px; width: 360px; text-align: center;
  box-shadow: var(--shadow-pop);
}
.auth-box .brand { justify-content: center; font-size: 16px; margin-bottom: 4px; }
.auth-box p { color: var(--text-2); font-size: 13.5px; margin: 10px 0 18px; }
.auth-box input {
  width: 100%; padding: 13px 15px; border: 1px solid var(--line);
  border-radius: var(--r-field); font-size: 16px; font-family: inherit; margin-bottom: 12px;
}
.auth-box input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-box button {
  width: 100%; background: var(--gem-spark); color: #fff; border: none;
  padding: 0; height: 48px; border-radius: var(--r-pill); font-weight: 500; cursor: pointer;
  font-family: inherit; font-size: 14px;
}
.auth-box .err { margin-top: 12px; }

/* ── Responsive ───────────────────────────────────────────────────── */
/* ── Responsive ───────────────────────────────────────────────────── */
/* Heading: one line on desktop/tablet, wraps cleanly on phones. */
@media (max-width: 760px) {
  .intro h1 { white-space: normal; font-size: clamp(23px, 6.6vw, 32px); }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 14.5px; }
  .brand small { display: none; }            /* drop the subtitle on phones */
  .page { padding: 4px 16px 56px; }
  .intro { padding: 36px 4px 24px; }
  .intro > p { font-size: 14.5px; }
  #composer { max-width: 100%; }
  .row { flex-direction: column; }
  .advanced .grid { grid-template-columns: 1fr; }
  #fetchBtn { width: 100%; }
  .card { padding: 18px; }
  .fetch-head { flex-direction: column; }
  .fetch-head h2 { font-size: 19px; }
  .actions { width: 100%; flex-direction: column; }
  .actions > * { width: 100%; justify-content: center; }
  .report-link { width: 100%; }
  .report-link a, .report-link .copy { flex: 1 1 auto; justify-content: center; }
  .settings { min-width: auto; width: 86vw; }
  dialog { padding: 20px; max-width: 92vw; }
}
/* Slightly tighter on very small phones. */
@media (max-width: 380px) {
  .prov-head, .kw-table td, .ai-list .ai-row { padding-left: 14px; padding-right: 14px; }
  .tabs { padding-left: 12px; padding-right: 12px; }
}
