/* ==========================================================================
   PT Meja Kreasi Sejahtera — design tokens

   Two brand themes, selected with data-theme on <html>:
     yellowtable  (default)  Night Shift — near-black with amber signage
     synaptic                Bright Signal — blue and white, future-tech

   Scales that do not change between themes live on :root.
   Color lives in the theme blocks below.

   Neon rule: neon tokens are for glows, rims and lines only. Never text.
   ========================================================================== */

:root {
  /* --- Type ------------------------------------------------------------ */
  --font-display: "Archivo", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter Tight", "Segoe UI", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: clamp(20px, 1.4vw + 16px, 24px);
  --text-xl: clamp(26px, 2.2vw + 19px, 34px);
  --text-2xl: clamp(32px, 4vw + 22px, 52px);
  --text-flap: clamp(38px, 9vw, 76px);

  --leading-tight: 1.15;
  --leading-snug: 1.35;
  --leading-body: 1.6;

  --tracking-flat: 0;
  --tracking-wide: 0.06em;
  --tracking-widest: 0.18em;

  /* --- Space — 4px rhythm ---------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* --- Radius ----------------------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* --- Motion ----------------------------------------------------------- */
  --dur-instant: 90ms;
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 380ms;
  --dur-flap: 300ms;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Layers ----------------------------------------------------------- */
  --z-ambient: -2;
  --z-base: 0;
  --z-raised: 10;
  --z-sticky: 20;
  --z-nav: 30;
  --z-overlay: 40;
  --z-modal: 50;
  --z-toast: 60;

  /* --- Shell ------------------------------------------------------------ */
  --topbar-h: 56px;
  --bottomnav-h: 60px;
  --shell-max: 1240px;
  --gutter: clamp(16px, 4vw, 32px);
  --tap-min: 44px;

  /* --- Control sizes ---------------------------------------------------- */
  --control-h-sm: 36px;
  --control-h: 44px;
  --control-h-lg: 52px;
}

/* The compact control size is a desktop density, not a touch one — on phones
   even the small variant has to clear the 44px target. */
@media (max-width: 600px) {
  :root {
    --control-h-sm: 44px;
  }
}

/* ==========================================================================
   Theme — Meja Kreasi (default)
   ========================================================================== */

:root,
[data-theme="yellowtable"] {
  color-scheme: dark;

  --bg: #0b0b0b;
  --surface: #141210;
  --surface-2: #1c1917;
  --surface-3: #262220;
  --surface-inset: #100e0c;

  --line: rgba(252, 178, 18, 0.14);
  --line-strong: rgba(252, 178, 18, 0.3);
  --line-neutral: rgba(255, 255, 255, 0.08);

  --ink: #f7f3ea;
  --ink-muted: #b5aa97;
  --ink-faint: #9d9384;
  --ink-inverse: #12100c;

  --brand: #fcb212;
  --brand-bright: #ffd36b;
  --brand-dim: rgba(252, 178, 18, 0.16);
  --brand-ink: #1a1204;
  --brand-text: #fcb212;
  /* The emphatic text tone. Bright on the dark ground, deep on the light one
     — the same role, not the same colour. */
  --brand-text-strong: #ffd36b;

  --accent: #ffd36b;
  --accent-ink: #1a1204;
  --accent-text: #ffd36b;

  --action: #fcb212;
  --action-ink: #1a1204;
  --action-bright: #ffd36b;

  /* Attendance + ledger semantics */
  --ok: #3ddc97;
  --ok-ink: #05231a;
  --ok-dim: rgba(61, 220, 151, 0.14);
  --late: #ff7a7a;
  --late-dim: rgba(255, 122, 122, 0.14);
  --early: #7effc9;
  --early-ink: #04231a;
  --early-dim: rgba(126, 255, 201, 0.14);
  --izin: #9dc0ff;
  --izin-dim: rgba(157, 192, 255, 0.14);

  --danger: #ff7a7a;
  --danger-dim: rgba(255, 122, 122, 0.14);
  --danger-ink: #2a0c0c;
  --warn: #ffb020;
  --warn-ink: #241703;
  --info: #8fd4ff;
  --info-ink: #06202e;

  /* Neon — glow, rim and line only */
  --neon-1: #00ffae;
  --neon-2: #ffb020;
  --glow-brand: 0 0 24px rgba(252, 178, 18, 0.28);
  --glow-neon: 0 0 20px rgba(0, 255, 174, 0.32);
  --rim: inset 0 1px 0 rgba(255, 255, 255, 0.05);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.55);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);
  --scrim: rgba(4, 3, 2, 0.72);

  /* Split-flap character: mechanical */
  --flap-face: #1c1917;
  --flap-face-2: #14110f;
  --flap-ink: #ffd36b;
  --flap-seam: rgba(0, 0, 0, 0.85);
  --flap-shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
  --flap-scan: transparent;

  /* Data series for charts and rank bars */
  --series-1: #fcb212;
  --series-2: #00ffae;
  --series-3: #9dc0ff;
  --series-4: #ff7a7a;
  --series-5: #d3a3ff;

  /* --- Liquid glass material -------------------------------------------
     Translucent surface that samples what sits behind it, with a specular
     rim along the light-facing edge. Kept dense enough that text on it still
     clears its contrast target. */
  --glass-bg: color-mix(in srgb, var(--surface) 84%, transparent);
  --glass-bg-strong: color-mix(in srgb, var(--surface) 88%, transparent);
  --glass-blur: 24px;
  --glass-saturate: 175%;
  --glass-border: rgba(255, 236, 200, 0.13);
  --glass-sheen: rgba(255, 236, 200, 0.5);
  --glass-rim: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);

  /* Translucent washes and edges. The legacy stylesheet layers surfaces with
     white alpha, which is invisible on a light ground — these carry the same
     layering into both themes. */
  /* Hover lifts a surface toward the viewer. In the dark theme that means
     adding light; in the light theme it means becoming more opaquely white.
     A single wash token cannot express that — mapping white alpha to ink made
     hover *darken* on the light theme, which is the opposite of the cue. */
  --hover-bg: rgba(255, 255, 255, 0.06);
  --hover-bg-strong: rgba(255, 255, 255, 0.1);

  --wash-1: rgba(255, 255, 255, 0.03);
  --wash-2: rgba(255, 255, 255, 0.05);
  --wash-3: rgba(255, 255, 255, 0.09);
  --edge: rgba(255, 255, 255, 0.08);

  --ambient:
    radial-gradient(ellipse 90% 40% at 50% -6%, rgba(252, 178, 18, 0.16), transparent 70%),
    radial-gradient(circle at 14% 22%, rgba(252, 178, 18, 0.1), transparent 46%),
    radial-gradient(circle at 86% 30%, rgba(255, 214, 140, 0.06), transparent 48%),
    radial-gradient(circle at 50% 88%, rgba(252, 178, 18, 0.08), transparent 55%);
}

/* ==========================================================================
   Theme — Synaptic
   ========================================================================== */

[data-theme="synaptic"] {
  color-scheme: light;

  --bg: #f4f8fc;
  --surface: #ffffff;
  --surface-2: #eaf2f9;
  --surface-3: #dde9f4;
  --surface-inset: #f7fbff;

  --line: rgba(91, 117, 152, 0.18);
  --line-strong: rgba(91, 117, 152, 0.36);
  --line-neutral: rgba(16, 32, 47, 0.08);

  --ink: #10202f;
  --ink-muted: #4a6480;
  /* Non-text only: icon strokes, gridlines, disabled marks. Muted *text*
     always uses --ink-muted, which clears 4.5:1 on every surface. */
  --ink-faint: #5d7691;
  --ink-inverse: #ffffff;

  --brand: #5b7598;
  --brand-bright: #7c97bb;
  --brand-dim: rgba(91, 117, 152, 0.12);
  --brand-ink: #ffffff;
  --brand-text: #3f5a7a;
  --brand-text-strong: #2f4a68;

  --accent: #00aeef;
  --accent-ink: #04222e;
  --accent-text: #006286;

  --action: #00aeef;
  --action-ink: #04222e;
  --action-bright: #2bc4fb;

  --ok: #076b4a;
  --ok-ink: #ffffff;
  --ok-dim: rgba(7, 107, 74, 0.12);
  --late: #b02525;
  --late-dim: rgba(176, 37, 37, 0.1);
  --early: #075f6b;
  --early-ink: #ffffff;
  --early-dim: rgba(7, 95, 107, 0.12);
  --izin: #2c52ae;
  --izin-dim: rgba(44, 82, 174, 0.12);

  --danger: #b02525;
  --danger-dim: rgba(176, 37, 37, 0.1);
  --danger-ink: #ffffff;
  --warn: #7f4b00;
  --warn-ink: #ffffff;
  --info: #075e8c;
  --info-ink: #ffffff;

  --neon-1: #00e5ff;
  --neon-2: #ff3dda;
  --glow-brand: 0 0 22px rgba(0, 174, 239, 0.26);
  --glow-neon: 0 0 22px rgba(0, 229, 255, 0.35);
  --rim: inset 0 1px 0 rgba(255, 255, 255, 0.9);

  --shadow-1: 0 1px 2px rgba(16, 32, 47, 0.08);
  --shadow-2: 0 8px 24px rgba(16, 32, 47, 0.1);
  --shadow-3: 0 24px 60px rgba(16, 32, 47, 0.14);

  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --scrim: rgba(16, 32, 47, 0.42);

  /* Split-flap character: holographic */
  --flap-face: #ffffff;
  --flap-face-2: #eaf2f9;
  --flap-ink: #10202f;
  --flap-seam: rgba(91, 117, 152, 0.35);
  --flap-shadow: 0 10px 22px rgba(16, 32, 47, 0.14);
  --flap-scan: rgba(0, 229, 255, 0.16);

  --series-1: #00aeef;
  --series-2: #5b7598;
  --series-3: #076b4a;
  --series-4: #b02525;
  --series-5: #7a5af8;

  --glass-bg: color-mix(in srgb, var(--surface) 86%, transparent);
  --glass-bg-strong: color-mix(in srgb, var(--surface) 86%, transparent);
  --glass-blur: 26px;
  --glass-saturate: 185%;
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-sheen: rgba(255, 255, 255, 0.95);
  --glass-rim: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 16px 40px rgba(16, 32, 47, 0.12);

  --hover-bg: rgba(255, 255, 255, 0.92);
  --hover-bg-strong: #ffffff;

  --wash-1: rgba(16, 32, 47, 0.03);
  --wash-2: rgba(16, 32, 47, 0.05);
  --wash-3: rgba(16, 32, 47, 0.09);
  --edge: rgba(91, 117, 152, 0.18);

  --ambient:
    repeating-linear-gradient(0deg, rgba(91, 117, 152, 0.05) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(91, 117, 152, 0.05) 0 1px, transparent 1px 40px),
    radial-gradient(circle at 18% 12%, rgba(0, 174, 239, 0.1), transparent 44%),
    radial-gradient(circle at 84% 24%, rgba(91, 117, 152, 0.1), transparent 46%),
    radial-gradient(circle at 50% 88%, rgba(0, 229, 255, 0.08), transparent 54%);
}

/* ==========================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

p,
ul,
ol,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  margin: 0;
}

/* Times, points, scores and rupiah amounts update in place — tabular figures
   stop the columns from jittering on every refresh. */
time,
.ui-num,
[data-num] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

a {
  color: var(--brand);
  text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent);
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-xs);
}

::selection {
  background: color-mix(in srgb, var(--brand) 35%, transparent);
  color: var(--ink);
}

/* Theme transition.

   Only while a switch is actually in flight — theme.js sets the attribute,
   then clears it. Leaving a transition on every element permanently would
   make each of them a transition candidate on any style change, which is
   real work on pages that render thousands of nodes.

   transform is deliberately absent so the split-flap keeps its own timing. */
html[data-theme-switching] body,
html[data-theme-switching] body * {
  transition:
    background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
