/* printables — styles for this module
   1. Games: பரமபதம் (Paramapadam) and ரேக்ளா பந்தயம் (Rekla race) — js/views/games.js
   2. Colour & trace worksheets — js/views/printables.js */

/* ---- 1a. பரமபதம் · Paramapadam ------------------------------------------------------ */
.ppd-layout { display: grid; gap: 22px; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .ppd-layout { grid-template-columns: minmax(0, 1fr); } }
/* The frame is red earth with a white rice-flour kolam, in every theme */
.ppd-frame { position: relative; aspect-ratio: 1; width: 100%; padding: 6.4%; border-radius: var(--r-lg); background: #8A3A1E; box-shadow: var(--shadow-1); }
.ppd-frame-art { position: absolute; inset: 0; pointer-events: none; }
.ppd-kolam { width: 100%; height: 100%; display: block; }
.ppd-k-line { fill: none; stroke: #FFF6E2; stroke-width: .45; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ppd-k-line { stroke-width: 1.6px; }
.ppd-k-dot { fill: #FFF6E2; }
.ppd-k-ring { fill: none; stroke: #F5C451; stroke-width: 2px; vector-effect: non-scaling-stroke; }
.ppd-board { position: relative; width: 100%; height: 100%; border-radius: 10px; overflow: hidden; background: var(--surface); }
.ppd-cell { position: absolute; width: calc(100% / 6); height: calc(100% / 6); display: grid; place-items: start; padding: 3px 5px; font: 700 .8rem var(--f-ui); color: var(--ink-2); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.ppd-cell.alt { background: var(--zari-soft); }
.ppd-cell.is-ladder { background: var(--leaf-soft); }
.ppd-cell.is-snake { background: var(--kumkum-soft); }
.ppd-cell.is-top { place-items: center; background: var(--marigold); color: #2B1514; padding: 2px; }
.ppd-top { display: grid; justify-items: center; line-height: 1.05; font-size: clamp(.9rem, 2.4vw, 1.3rem); }
.ppd-top-ml { font: 800 clamp(.5rem, 1.6vw, .7rem) var(--f-ml); }
.ppd-lines { position: absolute; inset: 0; pointer-events: none; }
.ppd-lines svg { width: 100%; height: 100%; display: block; }
.ppd-rail { stroke: #7A4A1E; stroke-width: 1.3; stroke-linecap: round; }
.ppd-rung { stroke: #A8672B; stroke-width: .9; stroke-linecap: round; }
.snk-body { fill: none; stroke: #2F7D3A; stroke-width: 3.2; stroke-linecap: round; }
.snk-band { fill: none; stroke: #F5C451; stroke-width: 1.2; stroke-linecap: round; stroke-dasharray: .1 3.2; }
.snk-head { fill: #2F7D3A; stroke: #1D5024; stroke-width: .4; }
.snk-eye { fill: #fff; }
.snk-tongue { fill: none; stroke: #B81D24; stroke-width: .45; stroke-linecap: round; }
.ppd-snake--1 .snk-body, .ppd-snake--1 .snk-head { stroke: #6A3D9A; } .ppd-snake--1 .snk-head { fill: #6A3D9A; stroke: #45246A; }
.ppd-snake--2 .snk-body { stroke: #B05A12; } .ppd-snake--2 .snk-head { fill: #B05A12; stroke: #7A3C08; }
.ppd-token { position: absolute; transform: translate(-50%, -50%); font-size: clamp(24px, 6vw, 38px); line-height: 1; transition: left .25s var(--ease), top .25s var(--ease); filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); z-index: 2; }
.ppd-side { display: grid; gap: 14px; justify-items: start; min-width: 0; }
.ppd-side .feedback { margin: 0; text-align: left; justify-content: flex-start; }
.ppd-die { font-size: 1.6em; line-height: 1; }
.ppd-quiz { display: grid; gap: 12px; justify-items: start; }
.ppd-quiz:empty { display: none; }
.ppd-opts { display: flex; flex-wrap: wrap; gap: 12px; }
.ppd-opt { position: relative; min-width: 76px; min-height: 76px; border: 3px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-md); padding: 8px; cursor: pointer; display: grid; place-items: center; }
.ppd-opt:hover:not(:disabled) { border-color: var(--peacock); }
.ppd-letter { font: 800 2.2rem/1.1 var(--f-ml); min-width: 84px; }
.ppd-opt .choice-mark { position: absolute; top: 2px; right: 6px; font: 800 1rem var(--f-ui); }
.ppd-opt.is-right { border-color: var(--leaf); background: var(--leaf-soft); }
.ppd-opt.is-wrong { border-color: var(--kumkum); background: var(--kumkum-soft); }
.ppd-opt:disabled { cursor: default; }
.ppd-word { font: 800 clamp(2rem, 1.4rem + 2vw, 2.8rem)/1.3 var(--f-ml); color: var(--ink); padding: 4px 18px; border-radius: var(--r-md); background: var(--zari-soft); border: 2px dashed var(--zari); }
.ppd-first { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
[data-contrast="high"] .ppd-cell { box-shadow: inset 0 0 0 1.5px var(--ink); color: var(--ink); }
[data-contrast="high"] .ppd-cell.is-top { color: #2B1514; }
[data-contrast="high"] .ppd-opt { border-color: var(--ink); }

/* ---- 1b. ரேக்ளா பந்தயம் · Rekla race ---------------------------------------------------- */
.rk-track { position: relative; display: grid; gap: 6px; padding: 16px 58px 12px 10px; border-radius: var(--r-lg); overflow: hidden; margin-bottom: 14px;
  background: repeating-linear-gradient(90deg, transparent 0 38px, rgba(90,58,20,.08) 38px 40px), linear-gradient(180deg, #9BC46B 0 10px, #E6C58A 10px, #D6A865); }
:root[data-theme="dark"] .rk-track { background: repeating-linear-gradient(90deg, transparent 0 38px, rgba(0,0,0,.14) 38px 40px), linear-gradient(180deg, #2E4A22 0 10px, #6A5030 10px, #4D3920); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rk-track { background: repeating-linear-gradient(90deg, transparent 0 38px, rgba(0,0,0,.14) 38px 40px), linear-gradient(180deg, #2E4A22 0 10px, #6A5030 10px, #4D3920); } }
.rk-lane { position: relative; height: 112px; border-bottom: 2px dashed rgba(255,255,255,.55); }
.rk-lane:last-of-type { border-bottom: 0; }
.rk-cart-wrap { position: absolute; bottom: 2px; left: calc(var(--p, 0) * (100% - 220px)); width: 220px; transition: left .9s var(--ease); }
.rk-cart { width: 100%; display: block; overflow: visible; }
.rk-finish { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 34px; }
.rk-tag { position: absolute; left: 4px; top: 2px; z-index: 1; font: 800 .72rem var(--f-ui); padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.92); color: #3A1410; white-space: nowrap; }
.rk-tag .ml { font: 700 .78rem var(--f-ml); }
.rk-lane.is-theirs .rk-tag { background: rgba(10,40,44,.82); color: #fff; }
.rk-wheel { transform-box: fill-box; transform-origin: center; }
.rk-leg { transform-box: fill-box; transform-origin: 50% 0; }
.is-running .rk-cart-wrap.is-ours .rk-wheel { animation: rkSpin .55s linear 2; }
.is-running .rk-cart-wrap.is-ours .rk-leg--0 { animation: rkTrot .28s ease-in-out 4; }
.is-running .rk-cart-wrap.is-ours .rk-leg--1 { animation: rkTrot .28s ease-in-out 4 reverse; }
@keyframes rkSpin { to { transform: rotate(360deg); } }
@keyframes rkTrot { 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }
.rk-q { display: grid; justify-items: center; gap: 10px; text-align: center; }
.rk-prompt { font-weight: 700; margin: 0; }
.rk-prompt .ml { font-family: var(--f-ml); }
.rk-opts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.rk-opt { min-width: 120px; min-height: 58px; padding: 8px 18px; border-radius: var(--r-md); border: 3px solid var(--line); background: var(--surface); color: var(--ink); font: 700 1.4rem var(--f-ml); cursor: pointer; }
.rk-opt:hover:not(:disabled) { border-color: var(--peacock); }
.rk-opt.is-right { border-color: var(--leaf); background: var(--leaf-soft); }
.rk-opt.is-wrong { border-color: var(--kumkum); background: var(--kumkum-soft); }
.rk-opt:disabled { cursor: default; }
[data-contrast="high"] .rk-opt { border-color: var(--ink); }
@media (max-width: 560px) { .rk-cart-wrap { width: 150px; left: calc(var(--p, 0) * (100% - 150px)); } .rk-lane { height: 84px; } .rk-track { padding-right: 44px; } .rk-finish { font-size: 26px; right: 8px; } }
@media (prefers-reduced-motion: reduce) { .rk-cart-wrap, .ppd-token { transition: none; } }
:root[data-motion="reduced"] .rk-cart-wrap, :root[data-motion="reduced"] .ppd-token { transition: none; }

/* ---- 2. Colour & trace -------------------------------------------------------------- */
.prn-sec { margin-top: 28px; }
.prn-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(46%, 180px), 1fr)); }
.prn-grid > li { display: grid; min-width: 0; }
.prn-card, .prn-ml { min-width: 0; overflow-wrap: anywhere; }
.prn-card { display: grid; gap: 4px; justify-items: center; align-content: start; text-align: center; min-height: 44px; padding: 16px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); transition: transform .2s var(--ease), border-color .2s; }
.prn-card:hover { transform: translateY(-2px); border-color: var(--zari); }
.prn-face { font: 800 1.9rem/1.3 var(--f-ml); color: var(--peacock-deep); }
.prn-ml { font: 700 1.08rem/1.35 var(--f-ml); }
.prn-en { font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.prn-note { font-size: .82rem; color: var(--ink-3); }
.prn-art { width: 100%; background: #fff; border-radius: 12px; padding: 6px; border: 1px solid var(--line); }
.prn-art svg { width: 100%; display: block; }
.prn-grid--small { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 10px; }
.prn-chip { display: grid; justify-items: center; gap: 0; min-height: 64px; padding: 8px 4px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); }
.prn-chip:hover { border-color: var(--zari); }
.prn-chip-ml { font: 800 1.7rem/1.25 var(--f-ml); color: var(--peacock-deep); }
.prn-chip-en { font-size: .8rem; color: var(--ink-3); font-weight: 600; }
[data-contrast="high"] .prn-card, [data-contrast="high"] .prn-chip { border: 2px solid var(--ink); }
.prn-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 18px; }
.prn-tools .muted { margin: 0; }

/* The sheet is paper: the same fixed colours in every theme */
.sht-wrap { overflow: hidden; }
.sht { --ink-s: #1B1B1B; --deep: #07434C; max-width: min(820px, 100%); margin: 0 auto; background: #fff; color: #1B1B1B; padding: 30px 36px 18px; border-radius: 8px; box-shadow: var(--shadow-2); display: grid; gap: 12px; min-width: 0; }
.sht .ml { font-family: "Noto Sans Tamil", "Baloo Thambi 2", sans-serif; }
.sht-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 8px 16px; border-bottom: 2px solid #1B1B1B; padding-bottom: 8px; }
.sht-head h1 { font: 800 1.4rem/1.3 var(--f-display); color: var(--deep); margin: 0; }
.sht-head h1 .ml { font-weight: 800; }
.sht-sub { color: #3A3A3A; margin: 0; font-size: .92rem; }
.sht-name { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; font-size: .92rem; color: #222; }
.sht-field { display: inline-flex; align-items: end; gap: 6px; white-space: nowrap; }
.sht-line { display: inline-block; width: min(170px, 34vw); height: 1.1em; border-bottom: 1.5px solid #333; }
.sht-line--short { width: min(100px, 22vw); }
.sht-foot { text-align: center; font-size: .75rem; color: #555; border-top: 1px solid #DDD; padding-top: 6px; }
.sht-dotted { display: block; width: 100%; height: auto; }
.sht-dotted .g-top { stroke: #C9C9C9; stroke-width: 1; stroke-dasharray: 4 4; }
.sht-dotted .g-base { stroke: #9A9A9A; stroke-width: 1.2; }
.sht-dotted .g-letter { font-family: "Noto Sans Tamil", "Baloo Thambi 2", sans-serif; font-weight: 700; fill: #F4F4F4; stroke: #6E6E6E; stroke-width: 1.3; stroke-dasharray: .2 3.2; stroke-linecap: round; stroke-linejoin: round; paint-order: fill; }
.sht-pic { font-size: 1.7rem; line-height: 1.1; display: inline-grid; place-items: center; }
.sht-pic svg { width: 2.2rem; height: 2.2rem; }
.sht-tr { font-size: .74rem; color: #555; font-style: italic; }

/* Trace rows */
.sht-rows { display: grid; }
.sht-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) minmax(0, .36fr) 96px; align-items: center; gap: 8px; border-bottom: 1px dashed #BBB; padding: 4px 0; }
.sht-model { display: grid; justify-items: center; line-height: 1.1; }
.sht-glyph { font: 700 3.2rem/1.15 "Noto Sans Tamil", "Baloo Thambi 2", sans-serif; color: var(--deep); }
.sht-mei { font-size: .9rem; color: #444; }
.sht-trace { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; }
.sht-own { border-left: 1px dashed #CCC; padding-left: 4px; min-width: 0; }
.sht-word { display: grid; justify-items: center; text-align: center; font-size: .95rem; line-height: 1.25; } .sht-word small { color: #555; }

/* உயிர்மெய் grid */
.sht-um { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid #BBB; border-left: 1px solid #BBB; }
.sht-cell { border-right: 1px solid #BBB; border-bottom: 1px solid #BBB; padding: 6px 8px 4px; display: grid; gap: 2px; min-width: 0; }
.sht-cell-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sht-cell-top .sht-glyph { font-size: 2.4rem; }
.sht-cell-meta { display: grid; line-height: 1.2; }
.sht-sum { font-size: .8rem; color: #333; }
.sht-hint { margin-left: auto; display: grid; justify-items: center; font-size: .72rem; line-height: 1.1; text-align: center; }
.sht-hint .sht-pic { font-size: 1.3rem; } .sht-hint .sht-pic svg { width: 1.6rem; height: 1.6rem; }
.sht-cell-trace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.sht-cell-own { padding-top: 2px; }

/* Colouring */
.sht-art { border: 2px solid #1B1B1B; border-radius: 12px; padding: 8px; }
.sht-art svg { width: 100%; display: block; }
.sht-caption { display: grid; justify-items: center; gap: 2px; text-align: center; color: #333; }
.sht-caption p { margin: 0; }
.sht-caption-word svg { height: 92px; width: auto; max-width: 100%; }
.sht-say { font-size: 1.1rem; color: #1B1B1B; }

/* Labels */
.sht-labels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sht-label { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 12px 6px; border: 2px dashed #999; margin: -1px 0 0 -1px; text-align: center; min-width: 0; }
.sht-label .sht-pic { font-size: 2.4rem; } .sht-label .sht-pic svg { width: 3rem; height: 3rem; }
.sht-label-ml { font: 800 1.6rem/1.3 "Noto Sans Tamil", "Baloo Thambi 2", sans-serif; color: var(--deep); overflow-wrap: anywhere; }
.sht-label small { color: #555; }

@media (max-width: 640px) {
  .sht { padding: 16px 12px; }
  .sht-row { grid-template-columns: 52px minmax(0, 1fr) 64px; }
  .sht-own { display: none; }
  .sht-glyph { font-size: 2.3rem; }
  .sht-um { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sht-hint { display: none; }
  .sht-labels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sht-label-ml { font-size: 1.3rem; }
}

/* Print: only the sheet, on one portrait A4 or Letter page (the smaller of the two: 190 × 255 mm) */
@page worksheet { size: portrait; margin: 10mm; }
@media print {
  body:has(.sht) { background: #fff !important; }
  body:has(.sht) .topbar, body:has(.sht) .rail, body:has(.sht) .tabbar, body:has(.sht) .crumbs, body:has(.sht) .hub-crumbs,
  body:has(.sht) .app-legal, body:has(.sht) .guest-note, body:has(.sht) #toasts, body:has(.sht) .skip-link, body:has(.sht) .prn-tools,
  body:has(.sht) .report-fab, body:has(.sht) .main > :not(.print-page) { display: none !important; }
  body:has(.sht) .shell, body:has(.sht) .main, body:has(.sht) .print-page, body:has(.sht) .sht-wrap { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; width: auto !important; min-height: 0 !important; box-shadow: none !important; overflow: visible !important; }
  .sht { page: worksheet; box-shadow: none; max-width: none; width: 100%; padding: 0; border-radius: 0; gap: 3mm; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sht-head h1 { font-size: 17pt; }
  .sht-row { grid-template-columns: 24mm minmax(0, 1fr) 32mm 30mm; height: min(40mm, calc(196mm / var(--rows, 6))); padding: 1mm 0; break-inside: avoid; }
  .sht-trace svg, .sht-own svg { max-height: calc(min(40mm, calc(196mm / var(--rows, 6))) - 3mm); width: auto; margin: 0 auto; }
  .sht-own { display: block; }
  .sht-glyph { font-size: 34pt; }
  .sht-um { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sht-cell { height: 49mm; break-inside: avoid; }
  .sht-hint { display: grid; }
  .sht-art svg { max-height: 150mm; }
  .sht-labels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sht-label { height: 40mm; break-inside: avoid; }
  .sht-label-ml { font-size: 20pt; }
}
