/* StageRate: smohith.com notebook style + a theatre-programme layer (tickets, key caps, sticky notes).
   Colour is flat and printed: palette blocks, navy ink, hard 2px edges and offset shadows. No gradients
   except the projector's spotlight. Thai falls back to IBM Plex Sans Thai glyph by glyph. */

@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 400; font-display: swap; src: url(/tools/stagerate/fonts/ibm-plex-sans-thai-thai-400-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 600; font-display: swap; src: url(/tools/stagerate/fonts/ibm-plex-sans-thai-thai-600-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 700 800; font-display: swap; src: url(/tools/stagerate/fonts/ibm-plex-sans-thai-thai-700-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }

:root {
  --bg: #F2F5FB; --line: #E1E7F4; --ink: #161C40; --muted: #4B5578; --accent: #3B60B5; --hand: #3B60B5;
  --card: #FFFFFF; --rule: #B9C4E0; --btn-bg: #161C40; --btn-fg: #F2F5FB; --edge: #161C40;
  --navy: #161C40; --night: #0B0F24;
  --yellow: #FFC75A; --blue: #8FB0F0; --teal: #7FD3C8; --pink: #F2B8D0; --mint: #A8DCC6; --sky: #8FC9F7; --lilac: #D9C2F5;
  --red: #B8392C; --ok: #1E766D;
  --f-display: "Bricolage Grotesque", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", "IBM Plex Sans Thai", ui-monospace, monospace;
  --f-hand: "Caveat", "IBM Plex Sans Thai", cursive;
  --pop: 4px 4px 0 var(--edge);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0F1328; --line: #1A2144; --ink: #EEF1FA; --muted: #A9B2D0; --accent: #8FB0F0; --hand: #FFC75A;
  --card: #171D3A; --rule: #3A4470; --btn-bg: #FFC75A; --btn-fg: #161C40; --edge: #000000;
  --red: #F2958A; --ok: #7FD3C8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background-color: var(--bg); color: var(--ink); font-family: var(--f-display);
  background-image: repeating-linear-gradient(transparent 0 39px, var(--line) 39px 40px);
  -webkit-font-smoothing: antialiased; line-height: 1.45;
}
:lang(th) body, body:lang(th) { line-height: 1.6; }
a { color: inherit; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--btn-bg); color: var(--btn-fg); padding: 10px 16px; z-index: 50; border-radius: 999px; }
.skip:focus { left: 16px; }
.mono { font-family: var(--f-mono); }
.hand { font-family: var(--f-hand); font-weight: 700; color: var(--hand); }
.dot-y { color: var(--yellow); }

/* ---------- top bar ---------- */
.bar { position: relative; z-index: 2; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px clamp(20px, 4vw, 48px); }
.brand { display: inline-flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand b { font-size: 26px; font-weight: 800; letter-spacing: -.035em; font-stretch: 80%; }
.brand small { font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.bar .spacer { flex: 1; }
.lab { font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 2px solid var(--edge); background: var(--card); color: var(--ink);
  font-family: var(--f-mono); font-size: 13px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; box-shadow: 3px 3px 0 var(--edge); transition: transform .12s, box-shadow .12s;
}
.btn:hover { color: inherit; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--edge); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--edge); }
.btn-main { background: var(--btn-bg); color: var(--btn-fg); transform: rotate(-1.5deg); }
.btn-main:hover { color: var(--btn-fg); transform: rotate(0) translate(-1px, -1px); }
.btn-y { background: var(--yellow); color: #161C40; } .btn-t { background: var(--teal); color: #161C40; }
.btn-p { background: var(--pink); color: #161C40; } .btn-b { background: var(--blue); color: #161C40; }
.btn-l { background: var(--lilac); color: #161C40; } .btn-m { background: var(--mint); color: #161C40; }
.btn-y:hover, .btn-t:hover, .btn-p:hover, .btn-b:hover, .btn-l:hover, .btn-m:hover { color: #161C40; }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--ink); box-shadow: none; transform: none; }
.btn-big { min-height: 60px; font-size: 15px; padding: 0 28px; }
.btn-wide { width: 100%; }
.btn-danger { color: var(--red); border-color: currentColor; box-shadow: none; background: transparent; }
.kbd { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border: 1.5px solid currentColor; border-radius: 6px; font-size: 12px; box-shadow: 0 2px 0 currentColor; opacity: .85; }

/* ---------- sheets, tickets, chips ---------- */
.sheet { position: relative; background: var(--card); border: 2px solid var(--edge); border-radius: 6px; padding: 26px 20px 20px; box-shadow: var(--pop); min-width: 0; }
.tab { position: absolute; top: -13px; left: 16px; font-family: var(--f-mono); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; padding: 4px 10px; color: #161C40; background: var(--yellow); border: 2px solid var(--edge); }
.tab.b { background: var(--blue); } .tab.t { background: var(--teal); } .tab.p { background: var(--pink); } .tab.l { background: var(--lilac); } .tab.m { background: var(--mint); }

/* Ticket: coloured stub + perforated tear line */
.ticket { position: relative; display: grid; grid-template-columns: 1fr; background: var(--card); border: 2px solid var(--edge); border-radius: 10px; box-shadow: var(--pop); overflow: hidden; color: var(--ink); text-decoration: none; transition: transform .15s; }
.ticket:hover { color: var(--ink); transform: translateY(-3px) rotate(-.5deg); }
.ticket .stub { padding: 22px 22px 18px; color: #161C40; border-bottom: 2px dashed var(--edge); position: relative; }
.ticket .stub::before, .ticket .stub::after { content: ""; position: absolute; bottom: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 2px solid var(--edge); }
.ticket .stub::before { left: -12px; } .ticket .stub::after { right: -12px; }
.ticket .body { padding: 18px 22px 22px; }
.ticket h2 { margin: 6px 0 0; font-size: clamp(28px, 3vw, 38px); line-height: .95; letter-spacing: -.035em; font-stretch: 80%; font-weight: 800; }
.ticket p { margin: 0 0 14px; color: var(--muted); }
.stub.y { background: var(--yellow); } .stub.t { background: var(--teal); } .stub.p { background: var(--pink); } .stub.b { background: var(--blue); } .stub.l { background: var(--lilac); }
.admit { font-family: var(--f-mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; padding: 4px 10px; border-radius: 999px; border: 1.5px solid var(--edge); color: #161C40; white-space: nowrap; }
.c0 { background: var(--yellow); } .c1 { background: var(--blue); } .c2 { background: var(--teal); } .c3 { background: var(--pink); }
.c4 { background: var(--mint); } .c5 { background: var(--sky); } .c6 { background: var(--lilac); }

/* Status: a symbol + a word + a colour, never colour alone */
.st { display: inline-flex; align-items: center; gap: 5px; font-family: var(--f-mono); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; color: #161C40; white-space: nowrap; }
.st-waiting { background: transparent; color: var(--muted); border: 1.5px dashed var(--rule); }
.st-stage { background: var(--yellow); } .st-performed { background: var(--teal); }
.st-absent { background: var(--pink); } .st-skipped { background: var(--lilac); }

.note { font-family: var(--f-hand); font-size: 24px; line-height: 1.1; color: var(--hand); transform: rotate(-2deg); }
.sticky { background: var(--yellow); color: #161C40; padding: 16px 18px; border: 2px solid var(--edge); box-shadow: var(--pop); transform: rotate(-1deg); }
.sticky.m { background: var(--mint); } .sticky.p { background: var(--pink); } .sticky.b { background: var(--blue); } .sticky.l { background: var(--lilac); }

input[type=text], input[type=search], input[inputmode=numeric], textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; border: 2px solid var(--edge); border-radius: 6px; background: var(--card); font-size: 18px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; background-image: repeating-linear-gradient(transparent 0 26px, var(--line) 26px 27px); background-attachment: local; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

.seg { display: inline-flex; border: 2px solid var(--edge); border-radius: 999px; overflow: hidden; }
.seg button { min-height: 40px; min-width: 48px; padding: 0 12px; border: 0; background: transparent; font-family: var(--f-mono); font-size: 12px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 999px; font-family: var(--f-mono); font-size: 13px; border: 2px solid var(--yellow); max-width: calc(100% - 32px); }
.conn { font-family: var(--f-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.conn.off::before { background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

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