/* ============================================================
   Mithqaly: homepage (price board, calculator, pieces near a weight)
   design: company/engineering/specs/2026-11-10-homepage-calculator-design.md
   look:   public/css/look.css (tokens, panels), approved mockup in
           .superpowers/brainstorm/homepage-bridge-look/
   Gold marks value: the live price, the calculator's result and the
   primary buttons; the download band is the page's one gold panel.
   ============================================================ */

.home .num { font-variant-numeric: tabular-nums lining-nums; }

/* ---- the top: board panel, then calculator panel ---- */
.home .home-top {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gutter);
  padding: 0 !important; background: none; box-shadow: none; border-radius: 0;
  margin-block: var(--gutter) calc(var(--gutter) / 2);
  animation: none;
}
.home .hb, .home .hc {
  position: relative; isolation: isolate;
  padding: 28px 20px;
  border-radius: var(--r-panel);
  background: linear-gradient(180deg, var(--panel-2), var(--panel) 220px);
  box-shadow: var(--panel-shadow);
}

/* ---- price board ---- */
.hb::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: -1; pointer-events: none;
  background-image: radial-gradient(oklch(0.74 0.125 80 / .16) 1px, transparent 1.4px);
  background-size: 18px 18px;
  -webkit-mask-image: radial-gradient(120% 70% at 50% 0%, #000 30%, transparent 75%);
          mask-image: radial-gradient(120% 70% at 50% 0%, #000 30%, transparent 75%);
}
.hb-live {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; margin: 0; max-width: 100%;
  padding: 4px 14px; border-radius: 999px; background: var(--well); box-shadow: var(--recessed);
  font-size: .8rem; font-weight: 700; color: var(--muted) !important;
}
.hb-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex: none;
  box-shadow: 0 0 0 3px oklch(0.66 0.13 160 / .18);
}
.hb-time:not(:empty)::before { content: '· '; }
.hb-h1 {
  margin: 18px 0 0; color: var(--ink);
  font-size: clamp(1.35rem, 5.6vw, 1.9rem); font-weight: 800; line-height: 1.3; letter-spacing: -.01em;
}
.hb-label { margin: 22px 0 0; font-size: .95rem; font-weight: 700; color: var(--muted) !important; }
.hb-price {
  margin: 0; color: var(--gold) !important; white-space: nowrap;
  font-size: clamp(4.1rem, 21vw, 9.25rem); font-weight: 900; line-height: .98; letter-spacing: -.045em;
  /* the glow is a filter on the whole number, not a text-shadow: while the
     digits roll each one sits in an overflow:hidden box (.hb-digit), which
     cut a text-shadow into a gold square per digit; a filter applies after */
  filter: drop-shadow(0 1px 0 oklch(0.9 0.1 88 / .25)) drop-shadow(0 18px 40px oklch(0.6 0.13 75 / .22));
}
.hb-price .num { display: inline-block; }
.hb-price-wait {
  font-size: clamp(1.7rem, 7vw, 2.4rem); letter-spacing: 0; white-space: normal;
  color: var(--muted) !important; filter: none;
}
.hb-unit {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  margin: 10px 0 0; font-size: .95rem; color: var(--muted) !important;
}
.hb-unit > span:first-child { font-weight: 700; }
.hb-delta {
  padding: 3px 12px; border-radius: 999px; background: var(--well); box-shadow: var(--recessed);
  font-weight: 700; font-size: .85rem; color: var(--ink);
}
.hb-delta:empty { display: none; }

.hb-rows { margin: 26px 0 0; }
.hb-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 14px 2px; border-top: 1px solid var(--line);
}
.hb-row:last-child { border-bottom: 1px solid var(--line); }
.hb-row dt { color: var(--muted); font-size: .95rem; }
.hb-row dt small { font-size: .75rem; color: var(--faint); }
.hb-row dd { margin: 0; color: var(--ink); font-weight: 800; font-size: 1.12rem; white-space: nowrap; }
/* السوق المحلي: hidden keeps its place (the general .is-hidden is display:none) */
.hb-local.is-hidden { display: flex !important; visibility: hidden; }

/* السوق المحلي / السعر العالمي: the karat track's look, at board size. Local is
   first, so in RTL it sits on the right and the thumb slides left for global. */
.hb-market {
  position: relative; display: inline-grid; grid-template-columns: 1fr 1fr;
  margin: 20px 0 0; padding: 4px; border-radius: 999px; background: var(--well); box-shadow: var(--recessed);
}
.hb-market[hidden] { display: none; }
.hb-market + .hb-label { margin-top: 16px; }
.hb-thumb {
  position: absolute; top: 4px; bottom: 4px; inset-inline-start: 4px; width: calc((100% - 8px) / 2);
  border-radius: 999px; background: var(--gold-fill); box-shadow: var(--gold-control);
  transition: transform .42s var(--ease-quint);
}
.hb[data-market="global"] .hb-thumb { transform: translateX(-100%); }
.hb-market button {
  position: relative; z-index: 1; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 999px; background: none; cursor: pointer;
  font: 800 .92rem 'Cairo', sans-serif; color: var(--muted);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: color .3s var(--ease-out);
}
.hb-market button[aria-pressed="true"] { color: var(--gold-ink); }
.hb-market button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hb[data-market="local"] .hb-only-global,
.hb[data-market="global"] .hb-only-local { display: none !important; }

.hb-more {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding-block: 4px;
  font-weight: 700; font-size: .95rem; color: var(--gold); text-decoration: none;
}
.hb-more::after { content: '←'; transition: transform .2s var(--ease-out); }
.hb-more:hover::after { transform: translateX(-4px); }

/* rolling digits on a live change (home.js); plain text the rest of the time */
.hb-digit { display: inline-block; height: 1em; overflow: hidden; vertical-align: top; }
.hb-reel { display: flex; flex-direction: column; transition: transform .8s cubic-bezier(.22, 1, .36, 1); }
.hb-reel > span { height: 1em; line-height: 1; }
.hb-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---- calculator ---- */
.hc-title {
  margin: 0 0 26px; text-align: center; color: var(--ink);
  font-size: clamp(1.9rem, 8.4vw, 3.5rem); font-weight: 900; line-height: 1.15; letter-spacing: -.02em;
}
.hc-title span { color: var(--gold); }
.hc-grid { display: grid; gap: 14px; }
.hc-device { padding: 20px 16px 18px; border-radius: 22px; background: var(--panel-2); box-shadow: var(--raised); }
.hc-lab { margin: 0 4px 10px; font-size: .88rem; font-weight: 700; color: var(--muted) !important; }
.hc-step { display: grid; grid-template-columns: 60px minmax(0, 1fr) 60px; gap: 10px; align-items: center; margin-bottom: 18px; }
.hc-btn {
  height: 60px; border: 0; border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, oklch(0.27 0.016 72), oklch(0.225 0.014 72));
  box-shadow: var(--raised); color: var(--gold);
  font: 600 1.9rem/1 'Cairo', sans-serif;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.hc-btn:active { transform: translateY(1px); box-shadow: var(--pressed); background: oklch(0.2 0.012 72); }
.hc-btn:disabled { color: var(--faint); cursor: default; }
.hc-weight {
  height: 72px; border-radius: 18px; background: var(--well); box-shadow: var(--recessed);
  display: flex; align-items: baseline; justify-content: center; gap: 8px; padding-top: 6px;
  color: var(--ink);
}
.hc-weight .num { font-size: 2.5rem; font-weight: 900; letter-spacing: -.03em; line-height: 1.4; }
.hc-weight small { font-size: .95rem; font-weight: 600; color: var(--muted); }

/* karats: a sunken track with a gold piece that slides to the choice */
.hc-karats {
  position: relative; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 5px; border-radius: 18px; background: var(--well); box-shadow: var(--recessed);
}
.hc-thumb {
  position: absolute; top: 5px; bottom: 5px; inset-inline-start: 5px; width: calc((100% - 10px) / 3);
  border-radius: 14px; background: var(--gold-fill); box-shadow: var(--gold-control);
  transform: translateX(calc(var(--k, 1) * -100%)); /* RTL: index 0 sits on the right */
  transition: transform .42s var(--ease-quint);
}
.hc-karats:not([style]) .hc-thumb { display: none; }
.hc-karats button {
  position: relative; z-index: 1; height: 52px; border: 0; border-radius: 14px; background: none; cursor: pointer;
  font: 800 1.25rem 'Cairo', sans-serif; color: var(--muted);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: color .3s var(--ease-out);
}
.hc-karats button[aria-pressed="true"] { color: var(--gold-ink); }

/* the result: a sunken receipt of numbered stops, lit one by one on a tap */
.hc-result {
  counter-reset: hc; display: grid; align-content: start;
  padding: 4px 16px; border-radius: 22px; background: var(--well); box-shadow: var(--recessed);
}
.hc-result > div {
  counter-increment: hc;
  display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 14px; padding: 16px 0;
}
.hc-result > div + div { border-top: 1px dashed var(--line); }
.hc-result > div::before {
  content: counter(hc);
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: .88rem; font-weight: 800; color: var(--muted);
  background: var(--panel-2); box-shadow: var(--raised);
  transition: background-color .35s var(--ease-out), color .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.hc-result > div.is-lit::before { background: var(--gold); color: var(--gold-ink); box-shadow: var(--gold-control); }
.hc-fee[hidden], .hc-near[hidden] { display: none !important; }
.hc-cap { margin: 4px 0 0; font-size: .88rem; font-weight: 600; color: var(--muted) !important; }
.hc-gold {
  margin: 2px 0 0; color: var(--gold) !important; white-space: nowrap;
  font-size: clamp(2.3rem, 10vw, 3.1rem); font-weight: 900; line-height: 1.15; letter-spacing: -.035em;
}
.hc-gold small { font-size: .9rem; font-weight: 600; letter-spacing: 0; color: var(--muted); margin-inline-start: 4px; }
.hc-how { margin: 4px 0 0; font-size: .8rem; color: var(--faint) !important; }
.hc-range { margin: 2px 0 0; white-space: nowrap; font-size: clamp(1rem, 4.6vw, 1.2rem); font-weight: 800; color: var(--ink) !important; }
.hc-near-link { display: inline-flex; gap: 6px; margin-top: 2px; font-weight: 800; color: var(--ink); text-decoration: none; }
.hc-near-link::after { content: '↓'; color: var(--gold); }
.hc-tick { animation: hc-tick .45s var(--ease-quint); }
@keyframes hc-tick { from { opacity: .2; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- pieces near that weight ---- */
.hp-title { margin: 0; font-size: clamp(1.5rem, 6.4vw, 2.4rem); font-weight: 900; line-height: 1.2; letter-spacing: -.015em; }
.hp-sub { margin: 4px 0 20px; font-size: .88rem; }
.hp-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.hp-card {
  display: flex; flex-direction: column; height: 100%; padding: 7px 7px 12px;
  border-radius: 20px; background: var(--panel-2); box-shadow: var(--raised);
  color: var(--ink); text-decoration: none;
  transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.hp-card:hover { transform: translateY(-3px); }
.hp-card:active { transform: none; box-shadow: var(--pressed); }
.hp-card img, .hp-noimg {
  display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 14px; background: var(--well);
}
.hp-name, .hp-meta, .hp-shop { padding-inline: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-name { padding-top: 10px; font-size: .95rem; font-weight: 800; color: var(--ink); }
.hp-meta { font-size: .78rem; color: var(--muted); }
.hp-shop { font-size: .78rem; color: var(--faint); }
.hp-price { margin-top: auto; padding: 8px 6px 0; font-size: 1.05rem; font-weight: 900; color: var(--ink); white-space: nowrap; }
.hp-all {
  display: block; text-align: center; line-height: 52px; margin-top: 24px; padding: 0 20px;
  border-radius: 999px; background: var(--gold-fill); color: var(--gold-ink); box-shadow: var(--gold-control);
  font-weight: 800; font-size: .95rem; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease-out);
}
.hp-all:hover { transform: translateY(-1px); }
.hp-all:active { transform: translateY(1px); box-shadow: inset 0 2px 4px oklch(0.35 0.08 65 / .6); }
.hp-grid.hc-tick > li { animation: hc-tick .5s var(--ease-quint) both; }
.hp-grid.hc-tick > li:nth-child(2) { animation-delay: .04s; }
.hp-grid.hc-tick > li:nth-child(3) { animation-delay: .08s; }
.hp-grid.hc-tick > li:nth-child(4) { animation-delay: .12s; }

/* ---- download: the page's one gold panel ---- */
.home main > .hd > .container.hd-inner {
  text-align: center; color: var(--gold-ink);
  background: var(--gold-fill);
  box-shadow: inset 0 1px 0 oklch(1 0.05 90 / .5), inset 0 -3px 0 oklch(0.45 0.09 65 / .5), var(--panel-shadow);
}
.hd-title { margin: 0 auto; max-width: 18ch; color: var(--gold-ink); font-size: clamp(1.75rem, 7.6vw, 3.25rem); font-weight: 900; line-height: 1.2; letter-spacing: -.02em; }
.hd-text { margin: 12px auto 0 !important; max-width: 46ch; font-weight: 600; color: oklch(0.3 0.05 70) !important; }
.hd-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 56px; margin-top: 24px; padding: 0 30px;
  border-radius: 999px; background: var(--dark-fill); color: var(--ink); text-decoration: none;
  font-weight: 800; font-size: 1rem;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / .1), 0 2px 3px oklch(0.3 0.06 70 / .4), 0 14px 26px -12px oklch(0.25 0.05 70 / .7);
  transition: transform .15s var(--ease-out);
}
.hd-btn svg { color: var(--gold); }
.hd-btn:hover { transform: translateY(-1px); }
.hd-btn:active { transform: translateY(1px); }
.hd-proof {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px;
  margin: 16px 0 0 !important; font-size: .85rem; font-weight: 700; color: oklch(0.3 0.05 70) !important;
}
.hd-proof svg { width: 17px; height: 17px; }
.hd-proof .dot { opacity: .5; }

.hc-btn:focus-visible, .hc-karats button:focus-visible, .hp-card:focus-visible,
.hp-all:focus-visible, .hb-more:focus-visible, .hc-near-link:focus-visible {
  outline: 2px solid var(--gold-hi); outline-offset: 3px;
}
.hd-btn:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 3px; }

/* ---- wide screens ---- */
@media (min-width: 900px) {
  .home .hb, .home .hc { padding: 52px 56px; }
  .hb {
    display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    column-gap: 64px; align-items: end;
  }
  .hb > * { grid-column: 1; }
  .hb > .hb-live, .hb > .hb-market { justify-self: start; }
  .hb-rows { grid-column: 2; grid-row: 1 / span 6; margin: 0; align-self: end; }
  .hb > .hb-more { grid-column: 2; grid-row: 7; justify-self: start; }
  .hc-title { margin-bottom: 44px; }
  .hc-grid { grid-template-columns: 1fr 1fr; gap: 28px; align-items: stretch; }
  .hc-result { padding: 8px 22px; }
  .hp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
  .hp-all { display: block; width: max-content; margin-inline: auto; padding: 0 28px; font-size: 1rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .hb-dot { animation: hb-live 2.4s ease-out infinite; }
  @keyframes hb-live {
    0% { box-shadow: 0 0 0 0 oklch(0.66 0.13 160 / .45); }
    70%, 100% { box-shadow: 0 0 0 7px oklch(0.66 0.13 160 / 0); }
  }
}
@media (prefers-reduced-motion: reduce) {
  .hb-reel, .hc-btn, .hc-thumb, .hb-thumb, .hb-market button, .hp-card, .hb-more::after, .hc-result > div::before { transition: none; }
}
