/* ======================================================================
   Albourse — chart page (chart.html)
   Hero (instrument + our snapshot + another symbol) → the chart (TradingView, or our own chart and the
   technical-analysis gauge for Tadawul) → how to read it → related news → popular symbols.
   Tokens only (both themes); 360–1600 px.
   ====================================================================== */

/* a market hue the shared heroes do not have (commodities) */
.page-hero--commodity { --accent: var(--commodity); --accent-ink: var(--commodity-ink); --accent-soft: var(--commodity-soft); }

/* ---------- hero ---------- */
.chart-hero { padding-bottom: clamp(26px, 2.4vw, 36px); }
.chart-hero__grid {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-areas: "copy snap" "find snap";
  gap: var(--sp-5) clamp(28px, 3.5vw, 56px); align-items: start; margin-top: var(--sp-4);
}
.chart-hero__copy { grid-area: copy; min-width: 0; }
.chart-hero__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: clamp(30px, 2vw + 18px, 50px); }
.chart-hero__name { min-width: 0; overflow-wrap: anywhere; }
.chart-hero__code {
  display: inline-flex; align-items: center; min-height: 32px; padding: 2px 12px; border-radius: 10px; flex: none;
  font-family: var(--font-mono); font-size: 15px; font-weight: 500; line-height: 1.4; letter-spacing: 0; color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.chart-hero__lead { max-width: 72ch; }
.chart-hero__lead bdi { font-family: var(--font-mono); font-size: .92em; }
.chart-hero__lead .num, .chart-facts .num, .chart-steps .num, .chart-snap__price .num { white-space: nowrap; }
.chart-hero__meta { margin-top: var(--sp-4); }
.chart-hero__delay { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); }
.chart-hero__delay .icon { width: 14px; height: 14px; }

/* ---------- snapshot card (our data) ---------- */
.chart-snap {
  grid-area: snap; position: relative; min-width: 0; padding: 18px 20px 16px; border-radius: 22px;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 74%, transparent); box-shadow: var(--shadow);
}
html[data-theme="light"] .chart-snap { background: color-mix(in srgb, var(--surface) 90%, transparent); }
.chart-snap__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.chart-snap__title { display: flex; align-items: center; gap: 9px; min-width: 0; font-family: var(--font-head); font-size: 17px; font-weight: 700; line-height: 1.45; }
.chart-snap__title .icon { width: 20px; height: 20px; flex: none; color: var(--accent, var(--text-3)); }
.chart-snap__more { min-height: 34px; padding: 0 10px; font-size: 13px; }
.chart-snap__what { margin-top: 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); line-height: 1.5; }
.chart-snap__px { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 2px; }
.chart-snap__price { font-family: var(--font-head); font-size: clamp(30px, 1.1vw + 22px, 40px); font-weight: 700; line-height: 1.25; }
.chart-snap__price .unit { font-family: var(--font-body); font-size: 16px; font-weight: 600; color: var(--text-2); }
.chart-snap__stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.chart-snap__stat { min-width: 0; padding: 9px 12px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.chart-snap__stat dt { font-size: 12px; font-weight: 600; line-height: 1.5; color: var(--text-3); }
.chart-snap__stat dd { margin: 3px 0 0; font-size: 15px; font-weight: 700; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; }
.chart-snap__stat dd .chg { font-size: 13px; }
.chart-snap__range { padding-top: 12px; }
.chart-snap__stamp { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-top: 12px; font-size: 12px; color: var(--text-3); line-height: 1.6; }
.chart-snap__stamp .stamp { font-size: 12px; }
.chart-snap__empty { display: grid; gap: 6px; justify-items: start; margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 14px; line-height: 1.75; color: var(--text-2); }
.chart-snap__empty-title { font-weight: 700; color: var(--text); }
.chart-snap__empty .mini-link { margin-top: 4px; }
.chart-snap__note { margin-top: 10px; font-size: 12.5px; color: var(--text-3); line-height: 1.7; }
.chart-snap__skel { padding: 4px 0; }
/* accepted formats (unknown symbol) */
.chart-formats { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.chart-formats a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 6px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; transition: border-color var(--t-fast), background-color var(--t-fast);
}
.chart-formats a:hover { border-color: var(--border-strong); background: var(--surface-3); }
.chart-formats code { font-family: var(--font-mono); font-size: 13.5px; font-weight: 500; }
.chart-formats span { font-size: 13px; color: var(--text-3); text-align: end; }

/* ---------- another symbol ---------- */
.chart-find { grid-area: find; min-width: 0; align-self: end; max-width: 580px; }
.chart-find__label { display: block; margin-bottom: 8px; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.chart-find__group { background: var(--surface); padding-inline-end: 4px; }
.chart-find__group .input { flex: 1 1 auto; min-width: 0; unicode-bidi: plaintext; text-align: right; }
.chart-find__group .input::-webkit-search-cancel-button { display: none; }
.chart-find__go { flex: none; }
.chart-find__hint { margin-top: 8px; font-size: 12.5px; line-height: 1.65; color: var(--text-3); }
.chart-find__hint.is-error { color: var(--neg); font-weight: 600; }

/* ---------- the chart ---------- */
.chart-main { padding-top: clamp(24px, 2.4vw, 32px); }
.chart-main__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; margin-bottom: 12px; }
.chart-main__title { font-family: var(--font-head); font-size: clamp(20px, .7vw + 16px, 26px); font-weight: 700; line-height: 1.45; }
.chart-main__sub { font-size: var(--fs-sm); line-height: 1.7; color: var(--text-3); max-width: 72ch; }
.chart-stage > .state { min-height: 280px; align-content: center; }
.chart-note, .chart-src { display: flex; align-items: flex-start; gap: 8px; }
.chart-note { margin: 0 0 12px; font-size: 13px; }
.chart-note .icon, .chart-src .icon { flex: none; width: 15px; height: 15px; margin-top: 3px; }
.chart-note--warn { color: var(--text-2); }
.chart-note--warn .icon { color: var(--warn); }
.chart-src { margin-top: 12px; }
.chart-state__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }

/* Tadawul: our chart + TradingView's technical-analysis gauge */
.chart-sa { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.chart-own, .chart-ta { min-width: 0; }
.chart-own .tile__head, .chart-ta .tile__head { flex-wrap: wrap; row-gap: 2px; }
.chart-own--empty { padding: 0; }
.chart-own--empty .state { border: 0; min-height: 300px; align-content: center; }
.chart-ta { padding-bottom: 16px; }
.chart-ta .tv-frame { box-shadow: none; }
.chart-ta__note { display: flex; align-items: flex-start; gap: 8px; }
.chart-ta__note .icon { flex: none; width: 15px; height: 15px; margin-top: 3px; }
.chart-honest { margin: var(--gap) 0 0; }
.chart-honest .callout__body a { color: var(--link); }

/* ---------- 01 read the chart ---------- */
.chart-read { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: var(--gap); align-items: start; }
.chart-about { display: grid; gap: 12px; }
.chart-about__title { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-size: 19px; font-weight: 700; line-height: 1.45; }
.chart-about__title .icon { width: 20px; height: 20px; flex: none; color: var(--accent, var(--text-3)); }
.chart-about__text { font-size: 15.5px; line-height: 1.9; color: var(--text-2); }
.chart-facts { display: grid; gap: 0; margin: 0; border-top: 1px solid var(--border); }
.chart-facts > div { display: grid; grid-template-columns: minmax(96px, 34%) minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.65; }
.chart-facts dt { color: var(--text-3); font-weight: 600; }
.chart-facts dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.chart-drivers { padding-top: 4px; }
.chart-drivers__title { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.6; }
.chart-drivers__list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.chart-drivers__list li { position: relative; padding-inline-start: 18px; font-size: 14.5px; line-height: 1.75; color: var(--text-2); }
.chart-drivers__list li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .78em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent, var(--text-3)); }
.chart-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: cstep; }
.chart-steps li {
  position: relative; counter-increment: cstep; display: grid; gap: 4px; padding: 14px 16px 14px 16px; padding-inline-start: 62px; min-height: 64px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 14.5px; line-height: 1.8; color: var(--text-2);
}
.chart-steps li::before {
  content: counter(cstep); position: absolute; inset-inline-start: 16px; top: 14px; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  font-family: var(--font-num); font-size: 15px; font-weight: 700; color: var(--accent-ink, var(--text)); background: var(--accent-soft, var(--surface-3));
}
.chart-step__title { font-weight: 700; color: var(--text); font-size: 15.5px; line-height: 1.6; }
.chart-steps a { color: var(--link); font-weight: 600; }
.chart-learn__title { margin-top: var(--sp-10, 40px); margin-bottom: var(--sp-4); font-family: var(--font-head); font-size: 19px; font-weight: 700; line-height: 1.45; }
.chart-learn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.chart-lcard {
  position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 76px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: inherit; text-decoration: none;
  transition: border-color var(--t-fast), transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.chart-lcard:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.chart-lcard__icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: var(--accent-ink, var(--text)); background: var(--accent-soft, var(--surface-3)); }
.chart-lcard__icon .icon { width: 21px; height: 21px; }
.chart-lcard__body { display: grid; gap: 2px; min-width: 0; }
.chart-lcard__body b { font-size: 15px; font-weight: 700; line-height: 1.55; color: var(--text); }
.chart-lcard__body small { font-size: 12.5px; line-height: 1.55; color: var(--text-3); }
.chart-lcard__go { width: 16px; height: 16px; color: var(--text-3); transition: transform var(--t-med) var(--ease-spring); }
.chart-lcard:hover .chart-lcard__go { transform: translateX(-4px); color: var(--text); }

/* ---------- 02 related news ---------- */
.chart-news__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: clamp(20px, 3vw, 40px); }
.chart-ncard { padding: 14px 0 16px; }
.chart-ncard .ncard__title { font-size: 18.5px; }
.chart-ncard__hit { min-height: 22px; padding: 1px 8px; border-radius: var(--radius-pill); font-size: 12px; background: var(--accent-soft, var(--surface-3)); color: var(--accent-ink, var(--text-2)); border-color: transparent; }
.chart-ncard__hit .icon { width: 12px; height: 12px; }
.chart-news__noscript { color: var(--text-3); font-size: 14.5px; }

/* ---------- 03 popular symbols ---------- */
.chart-pop { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.chart-pop__group { min-width: 0; padding: 18px 20px 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.chart-pop__title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-family: var(--font-head); font-size: 17px; font-weight: 700; line-height: 1.45; }
.chart-pop__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chart-pop .lchip { min-height: 38px; gap: 8px; padding: 0 12px 0 10px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.chart-pop__code { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-3); }
.chart-pop .lchip .chg { min-height: 0; padding: 0; background: none; border: 0; font-size: 12px; }
.chart-pop .lchip[aria-current="page"] { background: var(--accent-soft, var(--surface-3)); color: var(--accent-ink, var(--text)); border-color: color-mix(in srgb, var(--accent, var(--text-3)) 45%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, var(--text-3)) 35%, transparent); }
.chart-pop .lchip[aria-current="page"] .chart-pop__code { color: inherit; }

/* ---------- responsive ---------- */
@media (max-width: 1099px) {
  .chart-learn { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 999px) {
  .chart-hero__grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "copy" "snap" "find"; }
  .chart-find { max-width: none; }
  .chart-sa, .chart-read { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .chart-news__list, .chart-pop { grid-template-columns: minmax(0, 1fr); }
  .chart-learn { grid-template-columns: minmax(0, 1fr); }
  .chart-main__head { display: block; }
  .chart-main__sub { margin-top: 2px; }
}
@media (max-width: 520px) {
  .chart-snap { padding: 16px 14px 14px; border-radius: 18px; }
  .chart-snap__more { display: none; }   /* the breadcrumb links the market page too */
  .chart-snap__stat { padding: 8px 10px 9px; }
  .chart-hero__code { font-size: 13.5px; min-height: 28px; padding: 1px 10px; }
  .chart-find__go { padding: 0 14px; }
  .chart-find__more { display: none; }
  .chart-steps li { padding-inline-start: 56px; }
  .chart-steps li::before { inset-inline-start: 12px; }
  .chart-lcard { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px; }
  .chart-lcard__icon { width: 40px; height: 40px; border-radius: 12px; }
  .chart-pop__group { padding: 16px 14px 16px; }
}
@media (pointer: coarse) {
  .chart-pop .lchip { min-height: 44px; }
  .chart-snap__more { min-height: 44px; }
}
@media print {
  .chart-find, .chart-stage .tv-frame, .chart-popular { display: none !important; }
}
