/* ============================================================
   نتيجة الثانوية العامة — "السجل / The Record"
   Aesthetic: warm scholarly certificate. Cream parchment,
   deep teal-green ink, gold honor accents, diploma-grade card.
   ============================================================ */

:root {
  /* ── Palette ── */
  --ink:        #0e4a42;   /* deep teal-green — primary */
  --ink-deep:   #07332d;
  --ink-soft:   #2c6b61;
  --gold:       #c2982f;   /* honor / seal */
  --gold-bright:#d8af49;
  --gold-soft:  #ecd7a0;
  --paper:      #f5efdf;   /* page parchment */
  --paper-2:    #fbf7ec;   /* raised surfaces */
  --paper-3:    #fffdf7;   /* certificate sheet */
  --line:       #ddccab;   /* warm rules */
  --line-soft:  #ebdfc6;
  --text:       #241f17;   /* warm near-black */
  --muted:      #7a6f59;
  --pass:       #2c7a4f;
  --pass-bg:    #e6f0e4;
  --pass-line:  #bcd9bf;
  --fail:       #b03a2a;
  --fail-bg:    #f7e6df;
  --fail-line:  #e6c2b3;
  --warn:       #a9791b;

  /* ── Type ── */
  --f-display: "Aref Ruqaa", "Reem Kufi", serif;
  --f-head:    "Reem Kufi", "Tajawal", sans-serif;
  --f-body:    "Tajawal", "Reem Kufi", system-ui, sans-serif;

  /* ── Geometry ── */
  --radius:   18px;
  --radius-sm:12px;
  --shadow:   0 1px 2px rgba(7,51,45,.06), 0 18px 44px -22px rgba(7,51,45,.45);
  --shadow-lg:0 2px 6px rgba(7,51,45,.08), 0 40px 80px -30px rgba(7,51,45,.55);
  --ring-fx:  0 0 0 3px rgba(194,152,47,.32);
  --maxw: 920px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-body);
  color: var(--text);
  background: var(--paper);
  line-height: 1.65;
  letter-spacing: .1px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--gold-soft); color: var(--ink-deep); }

/* ── Decorative background ── */
.bg-grain {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
.bg-pattern {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .055;
  background-image:
    radial-gradient(circle at 0 0, transparent 11px, var(--ink) 12px, transparent 13px),
    radial-gradient(circle at 32px 32px, transparent 11px, var(--ink) 12px, transparent 13px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000, transparent 75%);
          mask-image: radial-gradient(circle at 50% 30%, #000, transparent 75%);
}

/* ============================================================
   Masthead
   ============================================================ */
.masthead {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,253,247,.9), rgba(245,239,223,.55));
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.masthead__inner {
  max-width: 1140px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand__seal { color: var(--gold); display: grid; place-items: center;
  filter: drop-shadow(0 2px 4px rgba(194,152,47,.35)); transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.brand:hover .brand__seal { transform: rotate(45deg); }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text strong { font-family: var(--f-head); font-weight: 700; font-size: 1.18rem; color: var(--ink-deep); }
.brand__text small { color: var(--muted); font-size: .78rem; }

.navtabs { display: flex; gap: 4px; margin-inline: auto; background: rgba(14,74,66,.06);
  border-radius: 12px; padding: 4px; }
.navtab {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--f-head); font-size: .92rem; font-weight: 500; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 9px; transition: background .2s, color .2s;
}
.navtab:hover { color: var(--ink-deep); }
.navtab.is-active { background: var(--ink); color: #fff; box-shadow: 0 6px 16px -8px rgba(7,51,45,.7); }

.masthead__year {
  font-family: var(--f-head); font-size: .82rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  background: var(--paper-2); white-space: nowrap;
}
.masthead__year span { font-weight: 700; }

/* ============================================================
   Stage / layout
   ============================================================ */
.stage { max-width: var(--maxw); margin: 0 auto; padding: 0 22px 80px; }

/* ============================================================
   Hero + search
   ============================================================ */
.hero { text-align: center; padding: clamp(30px, 6vw, 64px) 0 8px; }
.hero__kicker {
  font-family: var(--f-head); letter-spacing: 3px; font-size: .8rem;
  color: var(--gold); margin: 0 0 10px;
}
.hero__title {
  font-family: var(--f-display); font-weight: 700;
  font-size: clamp(2.2rem, 6.6vw, 4rem); line-height: 1.08; margin: 0;
  color: var(--ink-deep);
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.ornament {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 14px auto 8px; max-width: 320px; color: var(--gold);
}
.ornament span { height: 1px; flex: 1; background: linear-gradient(90deg, transparent, var(--gold) 60%, transparent); }
.ornament b { font-size: 1.3rem; line-height: 1; }
.hero__sub { color: var(--muted); font-size: clamp(.95rem, 2.4vw, 1.08rem); margin: 6px auto 0; max-width: 44ch; }

/* search card */
.search-card {
  position: relative; margin: 28px auto 0; max-width: 560px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.search-card::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--gold-soft);
  border-radius: calc(var(--radius) - 7px); pointer-events: none;
}

/* segmented toggle */
.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: rgba(14,74,66,.07); border-radius: 12px; padding: 4px; margin-bottom: 16px;
}
.seg__btn {
  position: relative; z-index: 2; border: 0; background: transparent; cursor: pointer;
  font-family: var(--f-head); font-size: .96rem; font-weight: 500; color: var(--ink-soft);
  padding: 10px 12px; border-radius: 9px; transition: color .25s;
}
.seg__btn.is-active { color: #fff; }
.seg__thumb {
  position: absolute; z-index: 1; top: 4px; bottom: 4px; width: calc(50% - 6px);
  right: 4px;
  background: var(--ink); border-radius: 9px;
  box-shadow: 0 6px 16px -8px rgba(7,51,45,.7);
  transition: transform .32s cubic-bezier(.4,1.2,.4,1);
}
.seg[data-mode="name"] .seg__thumb { transform: translateX(calc(-100% - 4px)); }

/* input row */
.field { display: flex; gap: 10px; }
.field__input {
  flex: 1; min-width: 0;
  font-family: var(--f-body); font-size: 1.18rem; font-weight: 500; color: var(--text);
  background: var(--paper-3);
  border: 1.5px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
  text-align: center; letter-spacing: 1px;
  transition: border-color .2s, box-shadow .2s;
}
.field__input::placeholder { color: #b3a88c; letter-spacing: normal; font-weight: 400; }
.field__input:focus { outline: none; border-color: var(--gold); box-shadow: var(--ring-fx); }
.field__btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-head); font-size: 1rem; font-weight: 700; color: #fff;
  background: linear-gradient(160deg, var(--ink-soft), var(--ink) 60%, var(--ink-deep));
  border: 0; border-radius: 12px; padding: 0 20px; cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(7,51,45,.9); transition: transform .15s, box-shadow .2s, filter .2s;
}
.field__btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.field__btn:active { transform: translateY(0); }
.field__hint { margin: 12px 2px 0; font-size: .85rem; color: var(--muted); text-align: center; }

/* data source badge */
.data-badge {
  display: inline-flex; align-items: center; gap: 8px; margin: 18px auto 0;
  font-size: .82rem; font-family: var(--f-head); color: var(--gold);
  background: rgba(194,152,47,.1); border: 1px solid var(--gold-soft);
  padding: 7px 14px; border-radius: 999px;
}
.data-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.data-badge.is-loading { color: var(--muted); border-color: var(--line); background: var(--paper-2); }
.data-badge.is-loading::before { background: var(--muted); animation: pulse 1s infinite; }
.data-badge.is-ready { color: var(--pass); border-color: var(--pass-line); background: var(--pass-bg); }
.data-badge.is-ready::before { background: var(--pass); }
@keyframes pulse { 50% { opacity: .25; } }

/* ============================================================
   Panels: loading / empty / matches
   ============================================================ */
.panel {
  max-width: 560px; margin: 26px auto 0; text-align: center;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 34px 26px;
  animation: rise .4s ease both;
}
.panel__icon { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }
.panel__title { font-family: var(--f-head); font-weight: 700; font-size: 1.25rem; color: var(--ink-deep); margin: 0 0 6px; }
.panel__text { color: var(--muted); margin: 0; }
.panel__text code { background: rgba(14,74,66,.08); border-radius: 5px; padding: 1px 6px; font-size: .9em; }

.loader { display: inline-flex; gap: 6px; }
.loader span { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); animation: bounce 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .3s; }

.matches { max-width: 640px; margin: 26px auto 0; }
.matches__head { font-family: var(--f-head); color: var(--ink-deep); font-weight: 700; margin: 0 0 12px; text-align: center; }
.match {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: right;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
  transition: transform .15s, border-color .2s, box-shadow .2s; font-family: var(--f-body);
  animation: rise .4s ease both;
}
.match:hover { transform: translateX(-4px); border-color: var(--gold); box-shadow: var(--shadow); }
.match__seat {
  font-family: var(--f-head); font-weight: 700; color: var(--ink); min-width: 86px;
  background: rgba(14,74,66,.08); border-radius: 8px; padding: 8px 10px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.match__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.match__name { font-weight: 700; color: var(--text); }
.match__meta { font-size: .82rem; color: var(--muted); }
.match__go { margin-inline-start: auto; color: var(--gold); font-size: 1.4rem; }

/* ============================================================
   Result actions
   ============================================================ */
.result-view { padding-top: 26px; animation: rise .45s ease both; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 22px; }
.action {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--f-head); font-weight: 700; font-size: .95rem;
  border-radius: 12px; padding: 11px 20px; transition: transform .15s, filter .2s, box-shadow .2s;
}
.action--solid { color: #fff; border: 0;
  background: linear-gradient(160deg, var(--ink-soft), var(--ink) 60%, var(--ink-deep));
  box-shadow: 0 10px 22px -12px rgba(7,51,45,.9); }
.action--ghost { color: var(--ink); background: var(--paper-2); border: 1.5px solid var(--line); }
.action--gold { color: var(--ink-deep); border: 0;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 70%, #a9791b);
  box-shadow: 0 10px 22px -12px rgba(194,152,47,.9); }
.action:hover { transform: translateY(-1px); filter: brightness(1.04); }
.action--ghost:hover { border-color: var(--gold); }
.action.is-busy { opacity: .7; pointer-events: none; }

/* ============================================================
   Certificate
   ============================================================ */
.certificate {
  position: relative; background: var(--paper-3);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: clamp(20px, 4vw, 40px);
  overflow: hidden;
}
.certificate::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 10px, var(--gold-bright) 10px 20px);
}
.certificate::after {
  content: ""; position: absolute; inset: 14px; border: 1.5px solid var(--gold-soft);
  border-radius: 10px; pointer-events: none;
}
.cert-inner { position: relative; z-index: 1; }

.cert-head { text-align: center; padding-bottom: 18px; border-bottom: 1.5px double var(--line); margin-bottom: 22px; }
.cert-head__auth { font-family: var(--f-head); font-size: .82rem; letter-spacing: 1px; color: var(--muted); margin: 0; }
.cert-head__title { font-family: var(--f-display); font-weight: 700; font-size: clamp(1.6rem, 4.5vw, 2.4rem); color: var(--ink-deep); margin: 4px 0 2px; }
.cert-head__year { font-family: var(--f-head); color: var(--gold); font-size: .9rem; }

/* student identity */
.cert-id { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.id-name {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(14,74,66,.05), transparent);
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 14px 18px;
}
.id-name__label { font-family: var(--f-head); color: var(--muted); font-size: .85rem; }
.id-name__value { font-family: var(--f-head); font-weight: 700; font-size: clamp(1.25rem, 3.4vw, 1.7rem); color: var(--ink-deep); }
.id-field { border: 1px solid var(--line-soft); border-radius: 12px; padding: 11px 14px; background: var(--paper-2); }
.id-field__label { font-family: var(--f-head); color: var(--muted); font-size: .76rem; margin: 0 0 2px; }
.id-field__value { font-weight: 700; color: var(--text); font-size: 1.02rem; margin: 0; }
.id-field--seat .id-field__value { font-family: var(--f-head); letter-spacing: 1.5px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── verdict banner: the percentage is the hero ── */
.verdict {
  position: relative; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  border-radius: 16px; padding: 20px; margin-bottom: 24px;
  border: 1.5px solid; overflow: hidden;
}
.verdict--pass    { background: var(--pass-bg); border-color: var(--pass-line); }
.verdict--second  { background: #fbf1dd; border-color: var(--gold-soft); }
.verdict--below   { background: #fbf1dd; border-color: var(--gold-soft); }
.verdict--fail    { background: var(--fail-bg); border-color: var(--fail-line); }
.verdict--absent  { background: #f0eee9; border-color: var(--line); }
.verdict--unknown { background: #f0eee9; border-color: var(--line); }

.verdict__ring { position: relative; flex: 0 0 auto; width: 128px; height: 128px; display: grid; place-items: center; }
.ring { transform: rotate(-90deg); }
.ring__track { fill: none; stroke: rgba(14,74,66,.12); stroke-width: 11; }
.ring__bar {
  fill: none; stroke: var(--ink); stroke-width: 11; stroke-linecap: round;
  animation: ringIn .9s cubic-bezier(.2,.8,.2,1) both;
}
.ring--pass   .ring__bar { stroke: var(--pass); }
.ring--second .ring__bar,
.ring--below  .ring__bar { stroke: var(--warn); }
.ring--fail   .ring__bar { stroke: var(--fail); }
.ring--absent .ring__bar,
.ring--unknown .ring__bar { stroke: #b9ae95; }
.ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__label b {
  display: block; font-family: var(--f-head); font-weight: 700;
  font-size: 1.5rem; line-height: 1.05; color: var(--ink-deep); font-variant-numeric: tabular-nums;
}
.ring__label small { font-size: .64rem; color: var(--muted); font-family: var(--f-head); }

.verdict__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; }
.verdict__status { font-family: var(--f-head); font-weight: 700; font-size: clamp(1.4rem, 4vw, 1.9rem); line-height: 1.15; }
.verdict--pass    .verdict__status { color: var(--pass); }
.verdict--second  .verdict__status,
.verdict--below   .verdict__status { color: var(--warn); }
.verdict--fail    .verdict__status { color: var(--fail); }
.verdict--absent  .verdict__status,
.verdict--unknown .verdict__status { color: var(--muted); }
.verdict__detail { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.verdict__flag {
  margin-top: 8px; font-size: .78rem; color: var(--warn);
  background: rgba(194,152,47,.12); border: 1px solid var(--gold-soft);
  border-radius: 8px; padding: 5px 10px; align-self: flex-start;
}
.verdict__stats { margin-inline-start: auto; display: flex; gap: 22px; text-align: center; }
.vstat b { display: block; font-family: var(--f-head); font-size: 1.4rem; color: var(--ink-deep); line-height: 1.1; font-variant-numeric: tabular-nums; }
.vstat span { font-size: .76rem; color: var(--muted); }

/* ranking strip */
.ranks { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 24px; }
.rank-card {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 14px 18px;
  background: linear-gradient(180deg, rgba(14,74,66,.04), transparent);
}
.rank-card__ic {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: grid; place-content: center;
  color: var(--ink); background: rgba(14,74,66,.08);
}
.rank-card.is-first { border-color: var(--gold-soft); background: linear-gradient(180deg, rgba(194,152,47,.12), transparent); }
.rank-card.is-first .rank-card__ic {
  color: #fff; background: radial-gradient(circle at 50% 32%, var(--gold-bright), var(--gold));
  box-shadow: 0 5px 14px -5px rgba(194,152,47,.7);
}
.rank-card__txt { display: flex; flex-direction: column; min-width: 0; }
.rank-card__label { font-family: var(--f-head); color: var(--muted); font-size: .82rem; }
.rank-card__value { font-family: var(--f-head); color: var(--ink-deep); font-size: 1.05rem; }
.rank-card__value b { font-size: 1.25rem; font-weight: 700; }
.rank-card.is-first .rank-card__value b { color: var(--gold); }
.rank-card__value small { color: var(--muted); font-weight: 400; font-size: .8rem; }

.ranks__note { margin: -14px 2px 22px; font-size: .8rem; color: var(--muted); }

/* tables */
.grades { margin-bottom: 24px; }
.grades__cap {
  display: flex; align-items: center; gap: 10px; margin: 0 2px 12px;
  font-family: var(--f-head); font-weight: 700; color: var(--ink-deep); font-size: 1.12rem;
}
.grades__cap::before { content: ""; width: 5px; height: 18px; border-radius: 3px; background: var(--gold); }
.cap-note { font-weight: 400; color: var(--muted); font-size: .78rem; }

.gtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .96rem;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gtable thead th {
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  color: var(--gold-soft); font-family: var(--f-head); font-weight: 700; font-size: .82rem;
  padding: 11px 12px; text-align: center; letter-spacing: .3px;
}
.gtable thead th:first-child { text-align: right; }
.gtable tbody td { padding: 11px 12px; text-align: center; border-top: 1px solid var(--line-soft); }
.gtable tbody td:first-child { text-align: right; font-weight: 500; }
.gtable tbody tr:nth-child(even) { background: rgba(14,74,66,.025); }
.gtable .score { font-family: var(--f-head); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.02rem; }
.gtable tr.is-total td { background: var(--ink); color: var(--paper-2); border-top: 2px solid var(--gold); }
.gtable tr.is-total td:first-child { color: #fff; font-family: var(--f-head); }
.gtable tr.is-total .score { color: var(--gold-bright); font-size: 1.1rem; }

/* distribution strip */
.dist { margin-bottom: 22px; }
.dist__chart {
  display: flex; align-items: flex-end; gap: 2px; height: 110px;
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 12px;
  background: linear-gradient(180deg, transparent, rgba(14,74,66,.04));
}
.dist__bar { flex: 1; border-radius: 3px 3px 0 0; background: rgba(14,74,66,.22); transition: background .2s; }
.dist__bar.is-me { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); box-shadow: 0 0 0 1px var(--gold); }
.dist__axis { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted);
  font-family: var(--f-head); padding: 6px 12px 0; }
.dist__note { margin: 4px 2px 0; font-size: .8rem; color: var(--muted); }

.cert-warn {
  background: rgba(194,152,47,.12); border: 1px solid var(--gold-soft); color: var(--warn);
  border-radius: 12px; padding: 12px 16px; font-size: .88rem; margin: 0 0 18px;
}

.cert-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 8px; padding-top: 18px; border-top: 1.5px double var(--line); color: var(--muted); font-size: .82rem;
}
.cert-foot__note { font-style: italic; }

/* ============================================================
   Board views (top students / statistics)
   ============================================================ */
.board-view { padding-top: 8px; animation: rise .45s ease both; }
.board-head { text-align: center; padding: clamp(24px, 5vw, 48px) 0 6px; }
.board-title {
  font-family: var(--f-display); font-weight: 700; margin: 0;
  font-size: clamp(1.9rem, 5.4vw, 3rem); color: var(--ink-deep);
}
.board-sub { color: var(--muted); margin: 4px auto 0; max-width: 46ch; font-size: .96rem; }

/* podium */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 24px 0 26px; align-items: end; }
.podium__card {
  display: flex; flex-direction: column; gap: 4px; text-align: center; cursor: pointer;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 14px; transition: transform .18s, box-shadow .22s, border-color .2s;
}
.podium__card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow); }
.podium__card--1 {
  order: 2; padding-block: 30px;
  background: linear-gradient(180deg, rgba(194,152,47,.16), var(--paper-2));
  border-color: var(--gold-soft);
}
.podium__card--2 { order: 1; }
.podium__card--3 { order: 3; }
.podium__rank { font-family: var(--f-head); font-size: .8rem; color: var(--gold); letter-spacing: 1px; }
.podium__card--1 .podium__rank { font-size: 1rem; font-weight: 700; }
.podium__name { font-family: var(--f-head); font-weight: 700; color: var(--ink-deep); font-size: 1.02rem; line-height: 1.35; }
.podium__score { font-family: var(--f-head); font-size: 1.3rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.podium__score small { font-size: .68rem; color: var(--muted); font-weight: 400; }
.podium__pct { font-family: var(--f-head); color: var(--gold); font-weight: 700; }
.podium__seat { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.board__hint { text-align: center; color: var(--muted); font-size: .88rem; margin: 0 0 12px; }
.board__table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: .94rem;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper-2);
}
.board__table thead th {
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  color: var(--gold-soft); font-family: var(--f-head); font-weight: 700; font-size: .8rem;
  padding: 10px 12px; text-align: center;
}
.board__table tbody tr { cursor: pointer; transition: background .15s; }
.board__table tbody tr:hover { background: rgba(194,152,47,.12); }
.board__table tbody td { padding: 10px 12px; text-align: center; border-top: 1px solid var(--line-soft); }
.board__i { font-family: var(--f-head); color: var(--muted); width: 56px; }
.board__name { text-align: right !important; font-weight: 500; }
.board__seat { font-variant-numeric: tabular-nums; color: var(--muted); }
.board__table .score { font-family: var(--f-head); font-weight: 700; font-variant-numeric: tabular-nums; }

/* statistics */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 22px 0; }
.statcard {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  position: relative; overflow: hidden;
}
.statcard::after {
  content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}
.statcard__k { font-family: var(--f-head); color: var(--muted); font-size: .84rem; }
.statcard__v { font-family: var(--f-head); font-size: 1.75rem; color: var(--ink-deep); line-height: 1.15; font-variant-numeric: tabular-nums; }
.statcard__s { font-size: .78rem; color: var(--muted); }

.chart-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 22px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 190px; }
.chart__bar {
  flex: 1; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  transition: filter .2s;
}
.chart__bar:hover { filter: brightness(1.4); }
.chart__foot { margin: 10px 2px 0; font-size: .8rem; color: var(--muted); text-align: center; }

.casebars { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.casebar__head { display: flex; justify-content: space-between; align-items: baseline; font-size: .9rem; }
.casebar__head b { font-family: var(--f-head); color: var(--ink-deep); font-variant-numeric: tabular-nums; }
.casebar__head small { color: var(--muted); font-weight: 400; }
.casebar__track { height: 10px; border-radius: 999px; background: rgba(14,74,66,.1); overflow: hidden; margin-top: 4px; }
.casebar__track span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  animation: growX .8s cubic-bezier(.2,.8,.2,1) both;
}
.statnote { margin-top: 8px; }
.statnote__p { color: var(--muted); font-size: .86rem; margin: 12px 2px 0; }

/* ============================================================
   Footer
   ============================================================ */
.site-foot { text-align: center; padding: 30px 22px 50px; color: var(--muted); font-size: .9rem; }
.site-foot p { margin: 2px 0; }
.dev-credit {
  display: inline-flex; align-items: center; gap: 7px; vertical-align: middle;
  font-family: var(--f-head); font-weight: 700; color: var(--ink);
  text-decoration: none; border-bottom: 1.5px solid transparent;
  transition: color .2s, border-color .2s;
}
.dev-credit svg { color: #25d366; }
.dev-credit:hover { color: var(--ink-deep); border-color: var(--gold); }

.visit-counter {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 14px;
  font-family: var(--f-head); font-size: .85rem; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 16px; box-shadow: var(--shadow);
  animation: rise .5s ease both;
}
.visit-counter svg { color: var(--gold); }
.visit-counter strong { font-weight: 700; color: var(--ink-deep); font-variant-numeric: tabular-nums; letter-spacing: .5px; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%,80%,100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes growX { from { transform: scaleX(0); transform-origin: right; } to { transform: scaleX(1); } }
@keyframes ringIn { from { stroke-dasharray: 0 1000; } }

.reveal { opacity: 0; animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .masthead__inner { flex-wrap: wrap; padding: 10px 16px; }
  .masthead__year { display: none; }
  .navtabs { margin-inline: 0 0; width: 100%; order: 3; }
  .navtab { flex: 1; padding: 8px 6px; font-size: .86rem; }
}
@media (max-width: 600px) {
  .field { flex-direction: column; }
  .field__btn { justify-content: center; padding: 13px; }
  .cert-id { grid-template-columns: 1fr; }
  .ranks { grid-template-columns: 1fr; }
  .verdict { justify-content: center; text-align: center; }
  .verdict__main { align-items: center; }
  .verdict__flag { align-self: center; }
  .verdict__stats { width: 100%; margin: 6px 0 0; justify-content: space-around;
    border-top: 1px dashed var(--line); padding-top: 12px; gap: 10px; }
  .podium { grid-template-columns: 1fr; }
  .podium__card--1 { order: 0; }
  .podium__card--2 { order: 1; }
  .podium__card--3 { order: 2; }
  .gtable, .board__table { font-size: .84rem; }
  .gtable thead th, .gtable tbody td,
  .board__table thead th, .board__table tbody td { padding: 9px 7px; }
  .board__seat { display: none; }
  .board__table thead th:last-child { display: none; }
  .chart { height: 150px; }
}

/* ============================================================
   Print — clean A4 certificate
   ============================================================ */
@media print {
  :root { --paper: #fff; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .bg-grain, .bg-pattern { display: none !important; }
  .stage { max-width: none; padding: 0; }
  .result-view { padding: 0; animation: none; }
  .certificate { box-shadow: none; border: 1px solid #bbb; border-radius: 0; }
  .certificate::after { border-color: var(--gold); }
  .reveal { animation: none !important; opacity: 1 !important; transform: none !important; }
  .ring__bar { animation: none !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  @page { margin: 12mm; }
}
