/* ============================================================================
   Fear & Greed — market sentiment section
   The hero (kicker / title / subtitle) mirrors the Market Calendar hero so both
   sections read as the same product surface.
   ========================================================================== */

/* Band palette. Five sentiment bands, tuned per theme so each colour keeps
   readable contrast as text on the panel background, not only as a fill. */
#fear-greed-page {
  --fg-band-1: #d92d20;   /* Extreme Fear   0–24  */
  --fg-band-2: #c2620a;   /* Fear          25–44  */
  --fg-band-3: #a16207;   /* Neutral       45–55  */
  --fg-band-4: #4d7c0f;   /* Greed         56–75  */
  --fg-band-5: #067a55;   /* Extreme Greed 76–100 */
  --fg-marker-ring: var(--panel);
  --fg-scale-gradient: linear-gradient(
    90deg,
    var(--fg-band-1) 0 25%, var(--fg-band-2) 25% 45%, var(--fg-band-3) 45% 55%,
    var(--fg-band-4) 55% 75%, var(--fg-band-5) 75% 100%
  );
  padding-bottom: 40px;
}
:root[data-theme="dark"] #fear-greed-page {
  --fg-band-1: #f87171;
  --fg-band-2: #fb923c;
  --fg-band-3: #fbbf24;
  --fg-band-4: #a3e635;
  --fg-band-5: #34d399;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) #fear-greed-page {
    --fg-band-1: #f87171;
    --fg-band-2: #fb923c;
    --fg-band-3: #fbbf24;
    --fg-band-4: #a3e635;
    --fg-band-5: #34d399;
  }
}

.fg-shell { display: grid; gap: 16px; }

/* ---- Hero: same rhythm and type scale as .earnings-hero ------------------ */
.fg-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 8px 2px; }
.fg-kicker { color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.fg-hero h2 { margin: 5px 0 0; font-family: var(--font-display); font-size: clamp(1.65rem, 2.6vw, 2.35rem); letter-spacing: -.035em; }
.fg-hero p { max-width: 720px; margin: 8px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.55; }

.fg-source {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--muted);
  font-size: .7rem; font-weight: 650; white-space: nowrap;
}
.fg-source::before {
  content: ""; width: 7px; height: 7px; flex: none; border-radius: 50%;
  background: var(--positive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 12%, transparent);
}
.fg-source.is-degraded { border-color: color-mix(in srgb, var(--warn) 34%, var(--border)); color: var(--warn); }
.fg-source.is-degraded::before { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 12%, transparent); }

/* ---- Cards --------------------------------------------------------------- */
.fg-main { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 16px; align-items: stretch; }
.fg-card {
  position: relative;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px;
  border: 1px solid var(--ui-border-soft, var(--border));
  border-radius: 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 78%, transparent), color-mix(in srgb, var(--panel) 94%, transparent)),
    var(--panel);
  box-shadow: var(--ui-shadow-premium, var(--shadow-md));
  overflow: hidden;
}
.fg-card > * { position: relative; z-index: 1; }
.fg-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--hairline); }
.fg-eyebrow { display: block; margin-bottom: 5px; font-size: .64rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; color: var(--accent); }
.fg-card-head h3 { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: -.025em; color: var(--text); }
.fg-head-hint { color: var(--muted-2); font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-align: right; }

/* ---- Gauge --------------------------------------------------------------- */
.fg-gauge-card { align-items: center; justify-content: space-between; }
.fg-gauge-card::before {                       /* soft band-tinted glow behind the dial */
  content: ""; position: absolute; pointer-events: none;
  width: 560px; height: 560px; left: 50%; top: -280px; transform: translateX(-50%);
  border-radius: 50%; opacity: .5;
  background: radial-gradient(circle, color-mix(in srgb, var(--fg-color, var(--accent)) 22%, transparent) 0%, transparent 64%);
}
/* Container query so the score scales with the dial rather than the viewport: on a narrow
   column a vw-sized number outgrows the arc it sits inside. The vw clamp below stays as the
   fallback for engines without container query units. */
.fg-gauge-wrap { position: relative; width: 100%; max-width: 620px; margin-inline: auto; container-type: inline-size; }
.fg-gauge { display: block; width: 100%; height: auto; overflow: visible; }
.fg-tick { fill: var(--muted-2); font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }

.fg-gauge-center {
  position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 62%; text-align: center;
}
.fg-score {
  font-size: clamp(2.2rem, 9vw, 5.4rem);
  font-size: clamp(2.2rem, 15cqw, 5.4rem);
  font-weight: 900; line-height: .84;
  letter-spacing: -.06em; font-variant-numeric: tabular-nums;
  color: var(--fg-color, var(--text));
}
.fg-score-scale { font-size: .68rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.fg-rating {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 100%; min-height: 32px; padding: 6px 14px;
  border-radius: 999px;
  font-size: .8rem; font-weight: 850; letter-spacing: .01em; white-space: nowrap;
  color: var(--fg-color, var(--text));
  border: 1px solid color-mix(in srgb, var(--fg-color, var(--border)) 42%, transparent);
  background: color-mix(in srgb, var(--fg-color, var(--surface-2)) 12%, var(--surface));
}
.fg-rating::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: currentColor; }

/* ---- Band legend: names each band and the range it covers ---------------- */
.fg-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; width: 100%; margin: 0; padding: 0; list-style: none; }
.fg-leg {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; padding: 7px 6px;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--muted); text-align: center;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}
.fg-leg-name { display: flex; align-items: center; gap: 6px; font-size: .68rem; font-weight: 800; line-height: 1.2; }
.fg-leg-name::before { content: ""; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--fg-leg-color); }
.fg-leg-range { font-size: .64rem; font-weight: 700; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.fg-leg.is-active {
  border-color: color-mix(in srgb, var(--fg-leg-color) 50%, transparent);
  background: color-mix(in srgb, var(--fg-leg-color) 12%, var(--surface));
  color: var(--fg-leg-color);
}
.fg-leg.is-active .fg-leg-range { color: inherit; opacity: .85; }
.fg-leg-1 { --fg-leg-color: var(--fg-band-1); }
.fg-leg-2 { --fg-leg-color: var(--fg-band-2); }
.fg-leg-3 { --fg-leg-color: var(--fg-band-3); }
.fg-leg-4 { --fg-leg-color: var(--fg-band-4); }
.fg-leg-5 { --fg-leg-color: var(--fg-band-5); }

/* ---- History ------------------------------------------------------------- */
.fg-previous { display: grid; gap: 10px; align-content: start; }
.fg-prev-item { display: grid; gap: 9px; padding: 13px 14px; border: 1px solid var(--hairline); border-radius: 14px; background: color-mix(in srgb, var(--surface-2) 66%, transparent); }
.fg-prev-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.fg-prev-label { font-size: .68rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.fg-prev-delta { font-size: .72rem; font-weight: 800; color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fg-prev-main { display: flex; align-items: baseline; gap: 9px; }
.fg-prev-val { font-size: 1.5rem; font-weight: 900; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--fg-prev-color, var(--text)); }
.fg-prev-band { font-size: .72rem; font-weight: 800; color: var(--fg-prev-color, var(--muted)); }
.fg-prev-track { position: relative; height: 6px; border-radius: 999px; background: var(--fg-scale-gradient); opacity: .85; }
.fg-prev-dot {
  position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--fg-prev-color, var(--text));
  box-shadow: 0 0 0 2.5px var(--panel);
}

/* ---- Component breakdown ------------------------------------------------- */
.fg-components { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.fg-comp { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--hairline); border-radius: 14px; background: color-mix(in srgb, var(--surface-2) 62%, transparent); }
.fg-comp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fg-comp-label { font-size: .84rem; font-weight: 700; line-height: 1.35; color: var(--text-2); }
.fg-comp-value { font-size: 1.15rem; font-weight: 900; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--fg-comp-color, var(--muted)); }
.fg-comp-track { position: relative; height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--surface-3) 82%, transparent); overflow: hidden; }
.fg-comp-fill { display: block; height: 100%; border-radius: 999px; background: var(--fg-comp-color, var(--muted)); transition: width 480ms cubic-bezier(.22, 1, .36, 1); }
.fg-comp-band { display: flex; align-items: center; gap: 6px; font-size: .7rem; font-weight: 800; letter-spacing: .02em; color: var(--fg-comp-color, var(--muted)); }
.fg-comp-band::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }
.fg-note { margin: 0; padding-top: 14px; border-top: 1px solid var(--hairline); color: var(--muted); font-size: .82rem; line-height: 1.6; }
.fg-empty { margin: 0; padding: 16px 2px; color: var(--muted); font-size: .82rem; line-height: 1.55; }

/* ---- Error state --------------------------------------------------------- */
/* Carries .fg-card in the markup for the panel treatment; this only owns show/hide. */
.fg-error { display: none; align-items: flex-start; gap: 10px; }
.fg-error strong { font-size: 1rem; font-weight: 800; color: var(--text); }
.fg-error span { color: var(--muted); font-size: .85rem; line-height: 1.55; }
.fg-shell.is-error .fg-main,
.fg-shell.is-error .fg-components-card { display: none; }
.fg-shell.is-error .fg-error { display: flex; }

/* ---- Loading skeleton ---------------------------------------------------- */
.fg-shell.is-loading .fg-score,
.fg-shell.is-loading .fg-rating,
.fg-shell.is-loading .fg-prev-item,
.fg-shell.is-loading .fg-comp {
  color: transparent !important;
  border-color: transparent;
  background: linear-gradient(100deg, var(--surface-3) 25%, var(--surface-2) 42%, var(--surface-3) 60%);
  background-size: 220% 100%;
  animation: fg-shimmer 1.25s ease-in-out infinite;
}
.fg-shell.is-loading .fg-score { border-radius: var(--r-lg); }
.fg-shell.is-loading .fg-prev-item { min-height: 78px; }
.fg-shell.is-loading .fg-comp { min-height: 86px; }
.fg-shell.is-loading .fg-rating::before,
.fg-shell.is-loading .fg-score-scale,
.fg-shell.is-loading .fg-prev-item > *,
.fg-shell.is-loading .fg-comp > * { visibility: hidden; }
.fg-shell.is-loading .fg-gauge { opacity: .45; }
@keyframes fg-shimmer { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) {
  .fg-shell.is-loading .fg-score,
  .fg-shell.is-loading .fg-rating,
  .fg-shell.is-loading .fg-prev-item,
  .fg-shell.is-loading .fg-comp { animation: none; }
  .fg-comp-fill { transition: none; }
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1080px) {
  .fg-main { grid-template-columns: 1fr; }
  .fg-gauge-wrap { max-width: 420px; margin-inline: auto; }
}
@media (max-width: 900px) {
  .fg-hero { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 640px) {
  .fg-card { padding: 16px; border-radius: 16px; }
  .fg-hero p { font-size: .82rem; }
  .fg-scale { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fg-leg:last-child { grid-column: 1 / -1; }
  .fg-gauge-center { width: 70%; bottom: 8%; }
  .fg-components { grid-template-columns: 1fr; }
  .fg-card-head { flex-direction: column; gap: 6px; }
  .fg-head-hint { text-align: left; }
}

/* Fear & Greed — workspace layout. The page header deliberately remains unchanged. */
@media (min-width: 1081px) {
  #fear-greed-page .fg-shell { gap: 20px; }
  #fear-greed-page .fg-main {
    grid-template-columns: minmax(0, 1.45fr) minmax(330px, .55fr);
    gap: 20px;
    align-items: stretch;
  }
  #fear-greed-page .fg-gauge-card { min-height: 470px; padding: 28px; }
  #fear-greed-page .fg-gauge-wrap { max-width: 720px; }
  #fear-greed-page .fg-history-card { padding: 22px; }
  #fear-greed-page .fg-previous { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #fear-greed-page .fg-prev-item { padding: 12px; }
  #fear-greed-page .fg-components-card { padding: 24px 28px; }
  #fear-greed-page .fg-components { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  #fear-greed-page .fg-comp { min-height: 112px; padding: 16px; }
}

@media (min-width: 1500px) {
  #fear-greed-page .fg-main { grid-template-columns: minmax(0, 1.6fr) minmax(390px, .4fr); }
  #fear-greed-page .fg-components { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
