/* SFGI public site. Direction: "The printed annual" (tasteskill v2, seed 311644589), palette "Signal red, white". Arabic, right to left, type IBM Plex Sans Arabic. */

:root {
  /* palette */
  --bg: #ffffff;
  --surface: #f2f2f2;
  --surface-2: #e6e6e6;
  --ink: #0a0a0a;
  --muted: #5c5c5c;
  --accent: #d92b21;
  --accent-ink: #ffffff;
  --field-ink: #000000;
  --field-ink-text: #ffffff;
  --field-ink-soft: #b8b8b8;

  /* sentiment bands: red for fear, grey for neutral, blue for greed */
  --b-ef: #d92b21;
  --b-f: #ef8f88;
  --b-n: #c9c9c9;
  --b-g: #7fa9db;
  --b-eg: #1f5aa6;

  /* type: five steps */
  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1.02rem + 0.25vw, 1.25rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --step-head: clamp(2rem, 1.3rem + 3.2vw, 4rem);
  --step-display: clamp(3.25rem, 1rem + 7vw, 7rem);

  /* frame */
  /* on very wide screens the content stops at 1600px; coloured fields still run edge to edge */
  --margin: max(clamp(16px, 2vw, 32px), calc((100vw - 1600px) / 2));
  --axis: 42%;
  --gap-section: clamp(80px, 9vw, 160px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
    font-size: var(--step-body);
  line-height: 1.85;
  font-variant-numeric: lining-nums;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; transition: text-underline-offset 160ms, color 160ms; }
a:hover { text-underline-offset: 0.3em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, figure, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
.num, [data-bind$="score"], .gauge-value, .facts dd, .sum { font-variant-numeric: tabular-nums lining-nums; }

.skip { position: absolute; inset-inline-start: var(--margin); top: -100px; background: var(--ink); color: var(--bg); padding: 12px 16px; z-index: 10; }
.skip:focus { top: 8px; }

/* ---------- masthead: the bar ---------- */
.masthead { position: relative; }
.bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  min-height: 56px;
}
.wordmark {
  display: flex; align-items: center;
  padding: 0 var(--margin);
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: var(--step-lead); letter-spacing: 0;
  text-decoration: none;
}
.tab {
  display: flex; align-items: center; gap: clamp(16px, 2.4vw, 40px);
  width: calc(var(--axis) - 0px);
  padding: 0 var(--margin);
  background: var(--accent); color: var(--accent-ink);
}
.tab a { text-decoration: none; font-size: var(--step-small); font-weight: 500; }
.tab a:hover { text-decoration: underline; }
.bar-link { display: flex; align-items: center; padding: 0 var(--margin); font-size: var(--step-small); font-weight: 500; }


/* ---------- first screen: reading on the left, title on the axis ---------- */
.first {
  display: grid;
  grid-template-columns: var(--axis) 1fr;
  padding: clamp(56px, 7vw, 120px) var(--margin) 0;
  align-items: start;
}
.first-text { padding-inline-start: 0; }
.title {
  font-size: var(--step-display);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.18;
}
.title .line { display: block; overflow: hidden; padding-bottom: 0.22em; margin-bottom: -0.14em; }
.title .line > span { display: block; }
.standfirst { font-size: var(--step-lead); line-height: 1.45; max-width: 34ch; margin-top: 32px; }
.button {
  display: inline-flex; align-items: center; min-height: 52px; margin-top: 32px;
  padding: 0 28px; background: var(--ink); color: var(--bg);
  font-weight: 500; font-size: var(--step-body); text-decoration: none;
  transition: background 160ms, transform 160ms var(--ease-out);
}
.button:hover { background: var(--accent); }
.button:active { transform: translateY(2px); }

.reading { padding-inline-end: clamp(16px, 4vw, 64px); }
.gauge { position: relative; max-width: 520px; }
.gauge-svg { width: 100%; height: auto; display: block; overflow: visible; }
.gauge-bands path { stroke: var(--bg); stroke-width: 3; }
.gauge-ticks text { font-family: inherit; font-size: 15px; font-weight: 600; fill: var(--ink); }
.gauge-zones text { font-family: inherit; font-size: 13px; font-weight: 600; }
.gauge-needle { transform-origin: 200px 200px; transform: rotate(-90deg); transition: transform 1400ms var(--ease-out); }
.gauge-needle line { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.gauge-needle circle { fill: var(--ink); }
.gauge-read { display: flex; align-items: baseline; justify-content: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.gauge-value { font-size: var(--step-head); font-weight: 600; letter-spacing: 0; line-height: 1; }
.gauge-label { font-size: var(--step-lead); font-weight: 500; }
.reading-meta { display: flex; justify-content: center; gap: 8px 20px; flex-wrap: wrap; margin-top: 12px; font-size: var(--step-small); color: var(--muted); text-align: center; }
.reading-meta [data-bind="change"] { color: var(--ink); }

/* ---------- shared section frame ---------- */
section { padding: var(--gap-section) var(--margin) 0; }
.field-ink { background: var(--field-ink); color: var(--field-ink-text); padding-bottom: var(--gap-section); margin-top: var(--gap-section); }
.field-surface { background: var(--surface); padding-bottom: var(--gap-section); margin-top: var(--gap-section); }
.axis-grid { display: grid; grid-template-columns: var(--axis) 1fr; align-items: start; }
.axis-main { max-width: 40ch; }
.side { padding-inline-end: clamp(16px, 4vw, 64px); }
.side-note { font-size: var(--step-body); max-width: 30ch; align-self: end; }
.head { font-size: var(--step-head); font-weight: 600; letter-spacing: 0; line-height: 1.35; }
.head-small { font-size: var(--step-lead); font-weight: 600; letter-spacing: 0; line-height: 1.5; }
.lead { font-size: var(--step-lead); line-height: 1.7; margin-top: 24px; }

/* history */
.history .lead { color: var(--field-ink-text); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 24px; }
.facts dt { font-size: var(--step-small); color: var(--field-ink-soft); }
.facts dd { font-size: var(--step-lead); font-weight: 500; line-height: 1.3; }
.chart { position: relative; width: 100%; direction: ltr; }
.chart-main { margin-top: clamp(40px, 5vw, 72px); height: clamp(320px, 46vw, 560px); }
.chart-small { height: clamp(180px, 16vw, 230px); margin-top: 20px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }
.chart svg:focus-visible { outline-offset: 6px; }
.chart .grid line { stroke: var(--surface-2); stroke-width: 1; }
.chart .axis text { font-family: "IBM Plex Sans Arabic", "Geeza Pro", Tahoma, sans-serif; font-size: 13px; fill: var(--muted); }
.chart .band { opacity: 0.16; }
.chart .series { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cursor line { stroke: var(--accent); stroke-width: 1.5; }
.chart .cursor circle { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.chart .readout { font-family: "IBM Plex Sans Arabic", "Geeza Pro", Tahoma, sans-serif; }
.chart-readout { position: absolute; top: 0; left: 0; direction: rtl; font-size: var(--step-small); font-weight: 500; padding: 6px 10px; background: var(--ink); color: var(--bg); pointer-events: none; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity 120ms; }
.chart-readout.on { opacity: 1; }
.field-ink .chart .grid line { stroke: #262626; }
.field-ink .chart .axis text { fill: var(--field-ink-soft); }
.field-ink .chart .series { stroke: var(--field-ink-text); stroke-width: 2.5; }
.field-ink .chart .band { opacity: 0.22; }
.field-ink .chart .cursor circle { stroke: var(--field-ink); }
.field-ink .chart-readout { background: var(--bg); color: var(--ink); }

/* indicators board */
.board { display: grid; gap: 4px; margin-top: clamp(40px, 5vw, 72px); margin-inline: calc(12px - var(--margin)); }
.row {
  display: grid; grid-template-columns: var(--axis) 1fr;
  background: var(--surface);
  padding: clamp(24px, 3vw, 40px) max(20px, calc(var(--margin) - 12px));
  transition: background 200ms;
}
.row:hover { background: var(--surface-2); }
.row-name { font-size: var(--step-lead); font-weight: 600; letter-spacing: 0; line-height: 1.5; }
.row-score { margin-top: 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.row-score > span:first-child { font-size: var(--step-head); font-weight: 600; letter-spacing: 0; line-height: 1; }
.row-body { min-width: 0; }
.row-body p { max-width: 62ch; }
.status { display: inline-block; padding: 6px 12px; font-size: var(--step-small); font-weight: 600; line-height: 1.3; background: var(--b-n); color: var(--ink); }
.status[data-band="Extreme Fear"] { background: var(--b-ef); color: #fff; }
.status[data-band="Fear"] { background: var(--b-f); color: var(--ink); }
.status[data-band="Neutral"] { background: var(--b-n); color: var(--ink); }
.status[data-band="Greed"] { background: var(--b-g); color: var(--ink); }
.status[data-band="Extreme Greed"] { background: var(--b-eg); color: #fff; }

/* method: call and response column on the axis, key numbers in the side zone */
.method .scale { margin-top: clamp(40px, 5vw, 64px); }
.method .scale li { padding: 20px 16px; }
.method-side { position: sticky; top: 32px; padding-inline-end: clamp(16px, 4vw, 64px); }
.numbers { display: grid; gap: 28px; }
.numbers > div, .facts > div { display: flex; flex-direction: column-reverse; gap: 4px; }
.numbers dt { font-size: var(--step-small); color: var(--muted); max-width: 24ch; }
.numbers dd { font-size: var(--step-head); font-weight: 500; letter-spacing: 0; line-height: 1; font-variant-numeric: tabular-nums lining-nums; }
.method .column > * > :not(.response-wide) { max-width: 640px; }
.method .column > .head { max-width: 640px; }
.exchange { margin-top: 88px; }
.call-line { font-size: var(--step-lead); font-weight: 500; line-height: 1.35; }
.call { margin-top: 16px; padding: 20px 24px; background: var(--bg); }
.response { margin-top: 16px; margin-inline-start: 56px; display: grid; gap: 4px; max-width: 584px; }
.response li { display: grid; grid-template-columns: 9.5em 1fr; gap: 16px; padding: 14px 20px; background: var(--surface-2); }
.response li span:first-child { font-weight: 600; }
.response-scores li span:last-child { font-weight: 600; font-size: var(--step-lead); line-height: 1.2; }
.exchange-final .response-wide { max-width: none; background: var(--ink); color: var(--bg); padding: clamp(24px, 3vw, 40px); }
.sum { font-size: clamp(1.75rem, 1rem + 2.2vw, 3.25rem); font-weight: 500; letter-spacing: 0; line-height: 1.15; }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 32px; }
.scale li { padding: 14px 12px; display: grid; gap: 4px; font-size: var(--step-small); line-height: 1.3; }
.scale li span:first-child { font-weight: 600; }
.scale li:nth-child(1) { background: var(--b-ef); color: #fff; }
.scale li:nth-child(2) { background: var(--b-f); color: var(--ink); }
.scale li:nth-child(3) { background: var(--b-n); color: var(--ink); }
.scale li:nth-child(4) { background: var(--b-g); color: var(--ink); }
.scale li:nth-child(5) { background: var(--b-eg); color: #fff; }

/* notes: answers as reading text */
.notes { display: grid; grid-template-columns: var(--axis) 1fr; padding-bottom: var(--gap-section); }
.notes .head-small { position: sticky; top: 32px; }
.notes-text { columns: 2; column-gap: 56px; font-size: 1.125rem; line-height: 1.8; }
.notes-text p { break-inside: avoid; margin-bottom: 20px; }
.notes-text strong { font-weight: 600; }

/* footer: calm, charcoal, disclaimer and contact only */
.footer {
  background: #1c1c1c; color: #d4d4d4;
  padding: clamp(56px, 7vw, 96px) var(--margin) 32px;
}
.foot-grid { display: grid; grid-template-columns: var(--axis) 1fr 1fr; gap: 40px clamp(32px, 4vw, 64px); align-items: start; }
.foot-brand { font-size: var(--step-lead); font-weight: 600; color: #ffffff; line-height: 1.2; }
.foot-head { font-size: var(--step-body); font-weight: 600; color: #ffffff; line-height: 1.5; margin-bottom: 12px; }
.foot-col p { font-size: 1rem; line-height: 1.8; max-width: 52ch; }
.foot-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; color: #ffffff; font-weight: 600; }
.foot-link:hover { color: #ffffff; }
.foot-copy { margin-top: clamp(48px, 6vw, 80px); font-size: var(--step-small); color: #a3a3a3; }
.noscript { padding: 24px var(--margin); background: var(--ink); color: var(--bg); }
.load-error { color: var(--accent); }

/* ---------- motion ---------- */
.js .title .line > span { transform: translateY(105%); }
.js.ready .title .line > span { transform: none; transition: transform 900ms var(--ease-out); }
.js.ready .title .line:nth-child(2) > span { transition-delay: 110ms; }
.js .reveal { opacity: 0; transform: translateY(24px); }
.js .reveal.in { opacity: 1; transform: none; transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out); transition-delay: var(--d, 0ms); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .title .line > span, .js .reveal { transform: none; opacity: 1; }
  .js.ready .title .line > span, .js .reveal.in { transition: none; }
  .gauge-needle { transition: none; }
}

/* ---------- tablet ---------- */
@media (max-width: 1024px) {
  :root { --axis: 36%; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
  .notes-text { columns: 1; }
  .tab { width: auto; }
  /* today's reading comes straight after the title, inside the first screen */
  .first { grid-template-columns: 1fr; }
  .first-text { display: contents; }
  .title { order: 1; }
  .reading { order: 2; padding: 0; margin-top: 32px; }
  .standfirst { order: 3; }
  .first .button { order: 4; justify-self: start; }
  .gauge { margin-inline: auto; }
  .scale { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- phone: the axis collapses to the left margin ---------- */
@media (max-width: 760px) {
  :root { --axis: 100%; }
  .bar { grid-template-columns: auto 1fr; }
  .tab { width: auto; gap: 16px; }
  .bar-link { display: none; }
  .first { padding-top: 28px; }
  .title { font-size: 12vw; }
  .standfirst { font-size: 1.0625rem; margin-top: 24px; }
  .reading { margin-top: 20px; }
  .gauge { max-width: 340px; }
  .axis-grid { grid-template-columns: 1fr; }
  .axis-grid .side { order: 2; margin-top: 32px; padding: 0; }
  .side-note { max-width: none; }
  .row { grid-template-columns: 1fr; }
  .row-body { margin-top: 20px; padding: 0; }
  .method-side { position: static; order: 2; margin-top: 64px; padding: 0; }
  .numbers { grid-template-columns: 1fr 1fr; }
  .notes .head-small { position: static; }
  .response { margin-inline-start: 0; }
  .response li { grid-template-columns: 1fr; gap: 2px; }
  .scale { grid-template-columns: 1fr; }
  .notes { grid-template-columns: 1fr; }
  .notes-text { margin-top: 24px; }
  .foot-grid { grid-template-columns: 1fr; gap: 32px; }
}

.method { position: relative; z-index: 1; }

/* beta tag beside the wordmark */
.wordmark { gap: 10px; }
.beta { font-size: var(--step-small); font-weight: 500; color: #bdbdbd; }

/* nav links: one line, full bar height so they are easy to tap */
.tab li { display: flex; }
.tab a { display: flex; align-items: center; min-height: 56px; white-space: nowrap; }
@media (max-width: 400px) {
  .tab { gap: 12px; padding: 0 16px; }
  .tab a { font-size: 0.8125rem; }
  .wordmark { padding: 0 16px; gap: 6px; }
}
@media (max-width: 350px) {
  .beta { display: none; }   /* the footer still says نسخة تجريبية */
}

/* large screens: the first screen fills the viewport, methodology text and the score bands sit side by side */
@media (min-width: 1025px) {
  .method { display: grid; grid-template-columns: var(--axis) 1fr; align-items: end; }
  .method .scale { margin-top: 0; }
  .method .axis-grid { grid-template-columns: 1fr; padding-inline-end: clamp(16px, 4vw, 64px); }
}
