/*
 * theme.css — GBP Analytics. A calm, dense analytics tool in the spirit of
 * Plausible and Linear: a map-forest green brand, warm off-white paper,
 * amber and cornflower as the chart companions. Dark mode is a deep
 * evergreen night with a mint accent, not the light set inverted.
 */

:root {
  --canvas: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #eef0ea;
  --border: #dfe2d9;
  --border-strong: #b4b9ab;
  --ink: #17201b;
  --muted: #5a635c;
  --accent: #1f5f4a;
  --accent-hover: #184c3b;
  --accent-ink: #ffffff;
  --accent-text: #1d5a46;
  --accent-strong: #174a39;
  --accent-soft: #e1efe8;
  --accent-border: #a9cfbf;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #dcefe2;
  --success-strong: #116a33;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #f6e8d8;
  --warning-strong: #96450a;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #f6e0df;
  --danger-strong: #a11919;
  --chart-1: #1f5f4a;
  --chart-2: #de8a3a;
  --chart-3: #4f74c8;
  --chart-4: #c24d7c;
  --chart-5: #8a9a2e;
  --chart-6: #7b5cc4;

  --font-display: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 800;
  --display-tracking: -0.025em;
  --eyebrow-tracking: 0.08em;

  --radius-btn: 0.5rem;
  --radius-card: 0.875rem;
  --radius-input: 0.5rem;
  --card-pad: 1.25rem;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-raised: 0 12px 32px -8px rgba(0, 0, 0, 0.18);
  --btn-weight: 600;
}

html[data-theme="dark"] {
  --canvas: #0e1411;
  --surface: #151d19;
  --surface-2: #1c2621;
  --border: #27322c;
  --border-strong: #46524a;
  --ink: #e8eee9;
  --muted: #9ba69e;
  --accent: #5fc59c;
  --accent-hover: #7dd3b0;
  --accent-ink: #0b1a13;
  --accent-text: #6fd0a8;
  --accent-strong: #93dfbf;
  --accent-soft: #173327;
  --accent-border: #2c5a47;
  --success: #22a35a;
  --success-ink: #06140c;
  --success-soft: #142d1f;
  --success-strong: #6ccb93;
  --warning: #d98a3b;
  --warning-ink: #1a0f03;
  --warning-soft: #33251a;
  --warning-strong: #e8ab6c;
  --danger: #e05a5a;
  --danger-ink: #1a0505;
  --danger-soft: #361a1b;
  --danger-strong: #f09292;
  --chart-1: #5fc59c;
  --chart-2: #f0a35e;
  --chart-3: #7f9ef0;
  --chart-4: #e37aa4;
  --chart-5: #b5c652;
  --chart-6: #a68cf0;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-raised: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
}

/*
 * app.css — GBP Analytics' own pieces: the app shell, KPI tiles, change
 * badges, the keyword bars, review list, code blocks and the auth screen.
 * Tokens only.
 */

.font-display { font-family: var(--font-display); }
.icon-xs { width: 0.875rem; height: 0.875rem; }

/* ---- Shell ---------------------------------------------------------------- */
.app-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1fr); }
.sidebar { display: none; }
@media (min-width: 64rem) {
  .app-shell { grid-template-columns: 16rem minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 1.75rem;
    padding: 1.25rem 0.875rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .topbar { display: none; }
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.625rem 1rem;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 0.5rem;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark .icon { width: 1.125rem; height: 1.125rem; }
.brand-word { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; color: var(--ink); font-size: 1rem; }

.nav-label {
  padding: 0 0.625rem 0.375rem; font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--eyebrow-tracking); color: var(--muted);
}
.nav-link {
  display: flex; align-items: center; gap: 0.625rem; min-width: 0;
  padding: 0.5rem 0.625rem; border-radius: 0.5rem;
  font-size: 0.875rem; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: background-color 150ms, color 150ms;
}
.nav-link .icon { flex-shrink: 0; width: 1rem; height: 1rem; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-link-add { color: var(--accent-text); }

.user-chip {
  display: flex; flex: 1; min-width: 0; align-items: center; gap: 0.625rem;
  padding: 0.375rem 0.5rem; border-radius: 0.625rem; text-decoration: none;
}
.user-chip:hover, .user-chip.is-active { background: var(--surface-2); }

.mnav { position: relative; }
.mnav > summary { list-style: none; }
.mnav > summary::-webkit-details-marker { display: none; }
.mnav-panel {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 30;
  width: min(18rem, calc(100vw - 2rem)); max-height: 75vh; overflow-y: auto;
  padding: 1rem 0.75rem; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-raised);
}

.content { width: 100%; max-width: 82rem; margin: 0 auto; padding: 1.5rem 1rem 5rem; }
@media (min-width: 48rem) { .content { padding: 2.25rem 2rem 5rem; } }

.page-title {
  font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking);
  font-size: 1.75rem; line-height: 1.15; color: var(--ink);
  overflow-wrap: anywhere;
}
@media (min-width: 48rem) { .page-title { font-size: 2.125rem; } }
.section-title { font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; letter-spacing: -0.02em; }
.back-link { display: inline-flex; align-items: center; gap: 0.375rem; margin-bottom: 0.75rem; font-size: 0.8125rem; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--ink); }

/* ---- Filters ---------------------------------------------------------------- */
.filter-bar {
  display: flex; flex-direction: column; gap: 0.625rem;
  margin-bottom: 1.25rem; padding: 0.875rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
}
@media (min-width: 64rem) { .filter-bar { flex-direction: row; align-items: center; justify-content: space-between; } }
.select-compact { height: 2.25rem; font-size: 0.875rem; width: auto; }
.custom-range { display: flex; align-items: center; gap: 0.5rem; }
.custom-range[hidden] { display: none; }
@media (max-width: 40rem) { .custom-range { display: grid; grid-template-columns: 1fr auto 1fr; } .custom-range .btn { grid-column: 1 / -1; } .select-compact { width: 100%; } }

/* ---- KPI tiles & change badges ------------------------------------------------ */
.kpi { display: flex; flex-direction: column; gap: 0.375rem; }
.card.kpi > * + * { margin-top: 0; }
.kpi-label { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; font-weight: 500; color: var(--muted); }
.kpi-value {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em;
  font-size: 1.625rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink);
}
@media (min-width: 48rem) { .kpi-value { font-size: 2rem; } }
.mini-figure { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.delta {
  display: inline-flex; align-items: center; gap: 0.125rem; flex-shrink: 0;
  padding: 0.0625rem 0.375rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.delta-up { background: var(--success-soft); color: var(--success-strong); }
.delta-down { background: var(--danger-soft); color: var(--danger-strong); }
.delta-flat { background: var(--surface-2); color: var(--muted); }

.status-dot { display: inline-block; width: 0.5rem; height: 0.5rem; flex-shrink: 0; border-radius: 999px; background: var(--border-strong); }
.status-ok { background: var(--success); }
.status-warn { background: var(--warning); }
.status-bad { background: var(--danger); }

/* ---- Cards ------------------------------------------------------------------------ */
.loc-card .card-foot { justify-content: flex-start; }
.loc-link { color: var(--ink); text-decoration: none; }
.loc-link:hover { color: var(--accent-text); }
.other-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.625rem 0; border-bottom: 1px solid var(--border);
}
.other-row:last-child { border-bottom: 0; }
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* ---- Charts ------------------------------------------------------------------------- */
.chart-fail {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.8125rem; color: var(--muted); text-align: center; padding: 1rem;
}

/* ---- Keywords ---------------------------------------------------------------------- */
.kw-cell { position: relative; padding: 0.125rem 0; min-width: 10rem; }
.kw-bar {
  position: absolute; left: -0.5rem; top: -0.25rem; bottom: -0.25rem;
  border-radius: 0.375rem; background: var(--accent-soft);
}
.kw-text { position: relative; }

/* ---- Reviews ------------------------------------------------------------------------- */
.review-list { display: flex; flex-direction: column; }
.review { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.review:last-child { border-bottom: 0; }
.reply {
  margin-top: 0.75rem; padding: 0.625rem 0.875rem; border-radius: 0.625rem;
  background: var(--surface-2); border-left: 3px solid var(--accent);
}
.stars { display: inline-flex; gap: 1px; color: var(--chart-2); }
.stars .icon { width: 0.8125rem; height: 0.8125rem; fill: currentColor; }
.stars-lg .icon { width: 1.125rem; height: 1.125rem; }
.star-fill { fill: currentColor; color: var(--chart-2); }
.rating-big { font-family: var(--font-display); font-weight: 800; font-size: 3.5rem; line-height: 1; letter-spacing: -0.04em; }

/* ---- Code ------------------------------------------------------------------------------- */
.code-line {
  display: block; flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-input);
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink);
}
.code-inline {
  padding: 0.0625rem 0.3125rem; border-radius: 0.3125rem; background: var(--surface-2);
  font-family: var(--font-mono); font-size: 0.8em; color: var(--ink); overflow-wrap: anywhere;
}
.code-block {
  margin: 0; padding: 0.875rem 1rem; overflow-x: auto; border-radius: 0.625rem;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.6; color: var(--ink);
}
.key-real[hidden], .key-mask[hidden] { display: none; }

.steps { counter-reset: step; display: flex; flex-direction: column; gap: 0.875rem; font-size: 0.9rem; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.25rem; line-height: 1.55; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 0.75rem; font-weight: 700;
}
.steps-compact { font-size: 0.875rem; }

/* ---- Auth ---------------------------------------------------------------------------------- */
.auth-grid { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 64rem) { .auth-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.auth-panel {
  display: flex; flex-direction: column; padding: 2rem 1.25rem;
  background:
    radial-gradient(60rem 30rem at 0% 100%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--surface-2);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 64rem) { .auth-panel { padding: 2.5rem 3.5rem; border-bottom: 0; border-right: 1px solid var(--border); } }
.auth-panel .mt-auto { margin-top: 2.5rem; }
@media (min-width: 64rem) { .auth-panel .mt-auto { margin-top: auto; } }
.auth-headline {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.035em;
  font-size: 2.25rem; line-height: 1.05; text-wrap: balance;
}
@media (min-width: 64rem) { .auth-headline { font-size: 3.5rem; } }
.demo-hint {
  display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.875rem 1rem;
  border-radius: var(--radius-card); background: var(--accent-soft); color: var(--accent-strong);
}
.demo-hint .icon { flex-shrink: 0; margin-top: 0.125rem; }

/* ---- Motion: KPI tiles settle in once on first paint ---------------------------------------- */
@keyframes tile-in { from { transform: translateY(6px); } to { transform: none; } }
.kpi { animation: tile-in 360ms var(--ease-out, ease-out) both; }
html.reduced-motion .kpi { animation: none; }
