/*
 * Stat boxes (2026-09-21): the coloured .small-box counters of the home pages
 * (smallbox-*.php, pms_home.php, sms_home_login.php) and the white .sum-box
 * summary cards of report_overview.php.
 *
 * Look + motion only. The boxes keep their original colours, markup, links and
 * queries; rms_statbox_ux.js adds the classes used here (sb-*), counts the
 * numbers up and swaps the jQuery-knob canvas for an SVG ring.
 * Motion rules of the house: one shot on entry, or an answer to the cursor.
 * Nothing loops. Remove the loader block in sys_css.php to switch it all off.
 *
 * The red/purple banners are ".alert.small-box" - they are NOT counters and are
 * left alone everywhere (:not(.alert)).
 */
@media screen {

  /* ================= shared shell ================= */
  .small-box:not(.alert),
  .sum-box {
    --sb-mx: 50%;
    --sb-my: 0%;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(10, 20, 50, 0.10), 0 6px 16px rgba(10, 20, 50, 0.08);
    transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.28s ease;
    isolation: isolate;
  }
  html[data-theme] .small-box:not(.alert),
  html[data-theme] .sum-box { border-radius: 10px; }

  .small-box:not(.alert):hover,
  .sum-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 2px 4px rgba(10, 20, 50, 0.12), 0 16px 32px rgba(10, 20, 50, 0.18);
  }
  .small-box.sb-link { cursor: pointer; }
  .small-box.sb-link:active { transform: translateY(-1px) scale(0.985); transition-duration: 0.08s; }

  /* a soft light that follows the cursor (JS writes --sb-mx / --sb-my) */
  .small-box:not(.alert)::before,
  .sum-box::before {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    background: radial-gradient(260px circle at var(--sb-mx) var(--sb-my), rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 65%);
  }
  .sum-box::before {
    background: radial-gradient(280px circle at var(--sb-mx) var(--sb-my), var(--sb-glow, rgba(37, 99, 235, 0.10)), rgba(255, 255, 255, 0) 65%);
  }
  .small-box:not(.alert):hover::before,
  .sum-box:hover::before { opacity: 1; }

  /* ================= coloured counters (.small-box) ================= */
  /* depth on top of the original flat colour: light from the top-left corner */
  .small-box:not(.alert) {
    background-image:
      radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%),
      linear-gradient(160deg, rgba(255, 255, 255, 0.10), rgba(0, 0, 0, 0.10));
  }
  .small-box:not(.alert) > .inner {
    position: relative;
    z-index: 2;
    padding: 14px 16px 12px;
  }
  .small-box:not(.alert) > .inner a { text-decoration: none; display: block; }
  .small-box:not(.alert) h3 {
    font-size: 40px;
    line-height: 1.05;
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    -webkit-font-feature-settings: "tnum";
            font-feature-settings: "tnum";
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.10);
  }
  .small-box:not(.alert) p {
    margin: 0 0 6px 0;
    font-size: 15px;
    opacity: 0.95;
  }

  /* the artwork on the right: steadier at rest, answers the cursor */
  .small-box:not(.alert) .icon {
    z-index: 2;
    top: 12px;
    right: 14px;
    transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3), opacity 0.3s ease;
    transform-origin: 60% 60%;
    opacity: 0.92;
  }
  .small-box:not(.alert) .icon img { display: block; max-height: 72px; width: auto; }
  .small-box:not(.alert):hover .icon {
    font-size: 90px;                      /* the old hover grew the font; the transform does it now */
    transform: scale(1.12) rotate(-6deg);
    opacity: 1;
  }

  /* footer: a real call to action with an arrow that slides in */
  .small-box:not(.alert) > .small-box-footer {
    padding: 6px 0;
    font-size: 13px;
    letter-spacing: 0.2px;
    background: rgba(0, 0, 0, 0.14);
    transition: background 0.25s ease, color 0.25s ease, letter-spacing 0.25s ease;
  }
  .small-box:not(.alert) > .small-box-footer::after {
    content: "\2192";
    display: inline-block;
    margin-left: 6px;
    opacity: 0;
    transform: translateX(-8px);
    transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease;
  }
  .small-box:not(.alert):hover > .small-box-footer { color: #fff; background: rgba(0, 0, 0, 0.24); }
  .small-box:not(.alert):hover > .small-box-footer::after { opacity: 1; transform: translateX(0); }

  /* cards without the footer (scan times, student home): a round arrow in the corner answers
     the cursor - up-right when the card opens a new tab */
  .small-box.sb-nofoot::after {
    content: "\2192";
    position: absolute;
    right: 12px; bottom: 10px;
    z-index: 3;
    width: 24px; height: 24px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 23px;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.22);
    opacity: 0;
    transform: translateX(-8px);
    transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease;
    pointer-events: none;
  }
  .small-box.sb-nofoot.sb-blank::after { content: "\2197"; }
  .small-box.sb-nofoot:hover::after,
  .small-box.sb-nofoot:focus::after { opacity: 1; transform: translateX(0); }
  @media (hover: none) { .small-box.sb-nofoot::after { opacity: 0.7; transform: none; } }
  .small-box.sb-link:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

  /* nothing waiting: the card steps back so the ones with work stand out */
  .small-box.sb-zero:not(:hover) { filter: saturate(0.72); }
  .small-box.sb-zero:not(:hover) h3,
  .small-box.sb-zero:not(:hover) .icon { opacity: 0.72; }


  /* JS gives the cards of one row the same height (sb-eqbox): footer pinned to the bottom,
     so the float grid never leaves a hole on a phone */
  .small-box.sb-eqbox { display: flex; flex-direction: column; }
  .small-box.sb-eqbox > .inner { flex: 1 0 auto; }
  .small-box.sb-eqbox > .small-box-footer { margin-top: auto; }

  /* clock cards (scan in / scan out): "late" red on purple is unreadable - keep the
     meaning, make it legible */
  .small-box.sb-time h3 font[color="red" i],
  html[data-theme="dark"] .small-box.sb-time h3 font[color="red" i] {
    color: #fff !important;
    background: #e11d48;
    border-radius: 8px;
    padding: 0 10px 2px;
    margin-left: -2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    display: inline-block;
  }
  /* a red "--:--" only means "not scanned yet": no alarm */
  .small-box.sb-time.sb-pending h3 font[color="red" i],
  html[data-theme="dark"] .small-box.sb-time.sb-pending h3 font[color="red" i] {
    color: inherit !important;
    background: none;
    box-shadow: none;
    padding: 0;
    opacity: 0.75;
  }
  .small-box.sb-time.sb-late p::after {
    content: attr(data-sb-late);
    display: inline-block;
    margin-left: 8px;
    padding: 0 8px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 18px;
    background: rgba(255, 255, 255, 0.22);
    vertical-align: 1px;
  }

  /* ================= white summary cards (.sum-box) ================= */
  .sum-box {
    border: 1px solid rgba(15, 27, 61, 0.08);
  }
  .sum-box > .inner {
    position: relative;
    z-index: 2;
    padding: 16px 12px 14px;
  }
  .sum-box > .inner a { display: block; text-decoration: none; line-height: 1.35; }
  .sum-box > .inner a[href="#"] { cursor: default; }
  .sum-box h3 {
    font-size: 40px;
    line-height: 1.15;
    margin: 4px 0 12px 0;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    -webkit-font-feature-settings: "tnum";
            font-feature-settings: "tnum";
  }
  .sum-box .icon { display: none; }       /* an empty ion-bag glyph that never rendered */

  .sum-box > .sum-box-footer {
    position: relative;
    overflow: hidden;
    padding: 7px 8px;
    color: #fff;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(0, 0, 0, 0.10));
  }
  .sum-box > .sum-box-footer[href="#"] { cursor: default; }
  /* JS gives the cards of one row the same caption / footer height (sb-eq) */
  .sum-box > .sum-box-footer.sb-eq { display: flex; align-items: center; justify-content: center; }
  /* the share again, as a level behind the footer words */
  .sum-box > .sum-box-footer .sb-level {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: 0;
    background: rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.45);
    transition: width 1.3s cubic-bezier(0.2, 0.7, 0.2, 1);
    pointer-events: none;
  }
  .sum-box > .sum-box-footer .sb-level.is-zero { border-right-color: transparent; }
  .sum-box > .sum-box-footer .sb-ftxt { position: relative; }

  /* ---- the ring that replaces the knob canvas ---- */
  .sb-ring {
    position: relative;
    display: block;
    width: 104px;
    height: 104px;
    margin: 2px auto 0;
    color: #2563eb;                       /* JS writes the footer colour here */
  }
  .sb-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
  .sb-ring .sb-ring-track { fill: none; stroke: currentColor; stroke-opacity: 0.14; stroke-width: 9; }
  .sb-ring .sb-ring-bar {
    fill: none;
    stroke: currentColor;
    stroke-width: 9;
    stroke-linecap: round;
  }
  .sb-ring .sb-ring-bar.is-zero { stroke-linecap: butt; }   /* a round cap paints a dot at 0% */
  .sb-ring .sb-ring-val {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  .sb-ring .sb-ring-val small { font-size: 13px; margin-left: 1px; font-weight: bold; opacity: 0.8; }
  .sum-box:hover .sb-ring .sb-ring-bar { stroke-width: 11; }
  .sb-ring .sb-ring-bar { transition: stroke-dashoffset 1.4s cubic-bezier(0.2, 0.7, 0.2, 1), stroke-width 0.25s ease; }
  .sum-box .sb-knob-off { display: none !important; }

  /* ---- dark theme ---- */
  html[data-theme="dark"] .sum-box { border-color: #444; }
  html[data-theme="dark"] .sum-box > .inner a { color: #e6e6e6 !important; }
  html[data-theme="dark"] .sum-box::before {
    background: radial-gradient(280px circle at var(--sb-mx) var(--sb-my), rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 65%);
  }
  html[data-theme="dark"] .small-box:not(.alert),
  html[data-theme="dark"] .sum-box { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.35); }
  html[data-theme="dark"] .small-box:not(.alert):hover,
  html[data-theme="dark"] .sum-box:hover { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), 0 16px 32px rgba(0, 0, 0, 0.55); }

  /* ---- keyboard ---- */
  .small-box:not(.alert) a:focus-visible,
  .sum-box a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 4px; }
  .sum-box a:focus-visible { outline-color: #2563eb; }

  /* ---- phones: two cards per row ---- */
  @media (max-width: 767px) {
    .small-box:not(.alert) h3, .sum-box h3 { font-size: 28px; }
    .small-box.sb-time h3 { font-size: 24px; }
    /* the artwork is hidden on a phone: the arrow takes its corner, clear of the centred words */
    .small-box.sb-nofoot::after { top: 8px; right: 8px; bottom: auto; width: 20px; height: 20px; font-size: 12px; line-height: 19px; }
    .small-box.sb-time h3 font[color="red" i] { padding: 0 7px 1px; border-radius: 6px; }
    .sum-box h3 { font-size: 24px; white-space: normal; }
    .small-box:not(.alert) p { font-size: 13px; }
    .small-box:not(.alert) > .inner { padding: 12px 10px 8px; }
    .sb-ring { width: 84px; height: 84px; }
    .sb-ring .sb-ring-val { font-size: 20px; }
    .sum-box > .sum-box-footer { font-size: 12px; }
  }
}

/* ================= one-shot entrance + number pop ================= */
@media screen and (prefers-reduced-motion: no-preference) {
  @keyframes sbRise {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  @keyframes sbIcon {
    from { opacity: 0; transform: translateX(18px) scale(0.7) rotate(10deg); }
    to   { opacity: 0.92; transform: translateX(0) scale(1) rotate(0); }
  }
  @keyframes sbPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.12); }
    100% { transform: scale(1); }
  }
  /* CSS only, so a slowly streaming page never shows a card twice. "backwards": no
     transform is left behind when the animation ends. The delay walks along the
     cards of one row (they are consecutive col-* siblings). */
  .small-box:not(.alert),
  .sum-box { animation: sbRise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) var(--sb-d, 0s) backwards; }
  .small-box:not(.alert) .icon { animation: sbIcon 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) calc(var(--sb-d, 0s) + 0.18s) backwards; }
  [class*="col-"] + [class*="col-"] > .small-box,
  [class*="col-"] + [class*="col-"] > .sum-box { --sb-d: 0.08s; }
  [class*="col-"] + [class*="col-"] + [class*="col-"] > .small-box,
  [class*="col-"] + [class*="col-"] + [class*="col-"] > .sum-box { --sb-d: 0.16s; }
  [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] > .small-box,
  [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] > .sum-box { --sb-d: 0.24s; }
  [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] > .small-box { --sb-d: 0.32s; }
  [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] > .small-box { --sb-d: 0.40s; }
  [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] + [class*="col-"] > .small-box { --sb-d: 0.48s; }
  .sb-pop { display: inline-block; transform-origin: 0 60%; animation: sbPop 0.42s ease-out; }
  .sum-box .sb-pop { transform-origin: 50% 60%; }
}
@media (prefers-reduced-motion: reduce) {
  .small-box:not(.alert), .sum-box, .small-box:not(.alert) .icon,
  .sb-ring .sb-ring-bar, .sum-box > .sum-box-footer .sb-level { transition: none !important; }
}
