/* Cipher Challenge (games/cipher/): the shared look of the hub, challenges, toolkit, briefings and teacher pages */
:root{
  --navy:#002060; --navy-2:#0a2f7a; --red:#C8102E; --light:#EFF3F9; --line:#d8e0ee; --ink:#1a1a1a; --muted:#5a6478; --bg:#f4f6fb;
  --night:#0b1530; --night-2:#13224a; --glow:#3fe0c5; --amber:#ffb703; --plain:#0f7b6c; --sel:#ffe08a; --warn:#d9480f;
}
*{ box-sizing:border-box; }
body{ margin:0; font-family:"Segoe UI", Aptos, Calibri, Arial, sans-serif; background:var(--bg); color:var(--ink); }
header.cc{ background:linear-gradient(120deg, var(--navy) 0%, var(--night) 100%); color:#fff; padding:18px 24px 58px; }
header.cc .head{ max-width:1300px; margin:0 auto; }
header.cc h1{ margin:0; font-size:1.5rem; letter-spacing:.3px; }
header.cc p{ margin:6px 0 0; font-size:.92rem; color:#c7d3ea; }
main.cc{ max-width:1300px; margin:-40px auto 40px; padding:0 16px; }
.panel{ background:#fff; border-radius:14px; box-shadow:0 2px 10px rgba(0,32,96,.08); padding:14px 16px; margin-bottom:14px; }
.panel h2{ margin:0 0 8px; font-size:1.1rem; color:var(--navy); }
.panel h3{ margin:12px 0 6px; font-size:1rem; color:var(--navy); }
.muted{ color:var(--muted); }
.small{ font-size:.85rem; }
a{ color:var(--navy-2); }
.btn{ font:inherit; font-size:.88rem; font-weight:700; min-height:36px; padding:0 13px; border-radius:9px; border:1.5px solid var(--navy); background:#fff; color:var(--navy); cursor:pointer; display:inline-flex; align-items:center; gap:6px; text-decoration:none; }
.btn:hover{ background:var(--light); }
.btn.primary{ background:var(--red); border-color:var(--red); color:#fff; }
.btn.primary:hover{ background:#a90d26; }
.btn.dark{ background:var(--navy); color:#fff; }
.btn.dark:hover{ background:var(--navy-2); }
.btn.small{ min-height:28px; font-size:.8rem; padding:0 9px; }
.btn:disabled{ opacity:.45; cursor:default; }
.btn.again{ background:var(--red); border-color:var(--red); color:#fff; }
.row{ display:flex; flex-wrap:wrap; align-items:center; gap:8px 10px; }
.spacer{ flex:1 1 auto; }
input.txt, select.txt, textarea.txt{ font:inherit; font-size:.95rem; padding:7px 10px; border:1.5px solid var(--line); border-radius:8px; background:#fff; }
input.txt:focus, textarea.txt:focus{ outline:2px solid #9db4e0; border-color:#9db4e0; }
.chip{ font:inherit; font-size:.82rem; font-weight:700; padding:5px 11px; border-radius:999px; border:1.5px solid var(--navy); background:#fff; color:var(--navy); cursor:pointer; }
.chip.active{ background:var(--navy); color:#fff; }
.pill{ display:inline-block; padding:2px 9px; border-radius:999px; font-size:.75rem; font-weight:800; letter-spacing:.3px; }
.pill.a{ background:#e3f6f1; color:#0f6a5c; } .pill.b{ background:#fde7ea; color:#a10d25; }
.pill.done{ background:#1E8A4C; color:#fff; } .pill.lock{ background:#e6e9f0; color:#5a6478; }
.say{ min-height:1.2em; font-weight:700; color:var(--navy); }
.say.bad{ color:var(--red); }

/* the cipher text, letter by letter, with the guess for each letter under it */
.cipherbox{ background:var(--night); color:#e8f0ff; border-radius:12px; padding:14px 14px 10px; line-height:1; }
.ctext{ display:flex; flex-wrap:wrap; gap:10px 14px; max-height:var(--ctext-max, 48vh); overflow-y:auto; padding-right:4px; font-family:"Consolas","Cascadia Mono","Menlo",monospace; }
.ctext .tok{ display:inline-flex; }
.ctext .cell{ display:inline-flex; flex-direction:column; align-items:center; width:1.15em; font-size:var(--cfs, 21px); cursor:pointer; border-radius:4px; padding:2px 0; border:0; background:none; color:inherit; font-family:inherit; }
.ctext .cell .c{ color:#9fb4dc; font-weight:600; }
.ctext .cell .p{ color:var(--glow); font-weight:800; min-height:1.05em; margin-top:3px; }
.ctext .cell .p.none{ color:#40507a; }
.ctext .cell.punct{ cursor:default; width:auto; min-width:.45em; }
.ctext .cell.punct .c{ color:#c9d4ee; }
.ctext .cell.sel{ background:rgba(255,224,138,.22); }
.ctext .cell.sel .c{ color:var(--sel); }
.ctext .cell.colmark{ background:rgba(63,224,197,.13); }
.ctext.plain-only .cell .c{ display:none; }
.ctext.cipher-only .cell .p{ display:none; }
.plainout{ font-family:"Consolas","Cascadia Mono","Menlo",monospace; font-size:1.05rem; line-height:1.7; color:var(--glow); word-break:break-word; letter-spacing:.06em; }

/* the workspace: coded message beside the tools on a wide screen */
.wsgrid{ display:grid; grid-template-columns:minmax(0, 1fr); gap:12px; align-items:start; }
.wsgrid .wstools{ margin:0; }
@media (min-width:1100px){
  .wsgrid{ grid-template-columns:minmax(0, 1.05fr) minmax(0, 1fr); }
  .wsgrid .wsleft{ position:sticky; top:8px; }
  .wsgrid .ctext{ --ctext-max: calc(100vh - 290px); }
  .wsgrid .board{ grid-template-columns:repeat(13, minmax(0, 1fr)); }
}
@media print{ .wsgrid{ display:block; } .wsgrid .wstools{ display:none; } }

.ltable{ background:#fff; border-radius:12px; box-shadow:0 2px 10px rgba(0,32,96,.08); padding:8px 10px; margin-top:10px; }
table.lt{ border-collapse:collapse; width:100%; font-family:Consolas, monospace; table-layout:fixed; min-width:560px; }
table.lt th{ font-family:"Segoe UI", Arial, sans-serif; font-size:.72rem; color:var(--navy); text-align:left; width:46px; padding:0 4px 0 0; }
table.lt td{ border:1px solid var(--line); text-align:center; padding:1px 0; }
table.lt td.z{ color:#b8c1d4; }
table.lt .ltin{ width:100%; border:0; text-align:center; font:800 1rem Consolas, monospace; color:var(--plain); padding:3px 0; background:#f3fbf9; }
table.lt .ltin:focus{ outline:2px solid var(--amber); background:#fff7e0; }
table.lt .ltin.clash{ color:var(--warn); background:#ffe3d6; }
.wsleft{ min-width:0; }

/* the substitution board: one column per cipher letter */
.board{ display:grid; grid-template-columns:repeat(26, minmax(0, 1fr)); gap:3px; }
.bcell{ font:inherit; display:flex; flex-direction:column; align-items:center; border:1.5px solid var(--line); border-radius:7px; background:#fff; padding:3px 0 4px; cursor:pointer; min-width:0; }
.bcell .bar{ width:70%; background:#c5d2ea; border-radius:2px 2px 0 0; margin-top:2px; }
.bcell .bars{ height:34px; display:flex; align-items:flex-end; width:100%; justify-content:center; }
.bcell .n{ font-size:.66rem; color:var(--muted); }
.bcell .cl{ font-weight:800; color:var(--navy); font-family:Consolas, monospace; font-size:1.05rem; }
.bcell .pl{ font-weight:800; color:var(--plain); font-family:Consolas, monospace; font-size:1.15rem; min-height:1.3em; border-top:1px dashed var(--line); width:100%; text-align:center; margin-top:2px; }
.bcell.sel{ border-color:var(--amber); background:#fff7e0; }
.bcell.clash .pl{ color:var(--warn); }
.bcell.zero{ opacity:.45; }
.used{ display:flex; flex-wrap:wrap; gap:3px; font-family:Consolas, monospace; font-weight:800; }
.used span{ width:22px; text-align:center; border-radius:4px; padding:2px 0; background:#eef1f7; color:#9aa6bd; }
.used span.on{ background:#dff3ee; color:var(--plain); }
.used span.twice{ background:#ffe3d6; color:var(--warn); }

/* tabs of tools */
.tabs{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:10px; }
.tab{ font:inherit; font-size:.85rem; font-weight:700; padding:7px 12px; border-radius:9px 9px 0 0; border:1.5px solid var(--line); border-bottom:none; background:#f0f3f9; color:var(--navy); cursor:pointer; }
.tab.active{ background:var(--navy); color:#fff; border-color:var(--navy); }
.tool{ border-top:2px solid var(--navy); padding-top:12px; }

/* frequency charts */
.freq{ display:grid; grid-template-columns:repeat(26, minmax(0, 1fr)); gap:2px; align-items:end; }
.freq .fc{ display:flex; flex-direction:column; align-items:center; font-size:.7rem; color:var(--muted); min-width:0; }
.freq .fb{ width:100%; display:flex; align-items:flex-end; justify-content:center; gap:1px; }
.freq .fb i{ display:block; width:45%; border-radius:2px 2px 0 0; }
.freq .fb i.t{ background:var(--navy-2); } .freq .fb i.e{ background:#f4a3b0; }
.freq .fl{ font-weight:800; font-family:Consolas, monospace; color:var(--ink); font-size:.82rem; }
.key-legend{ display:flex; gap:14px; font-size:.8rem; color:var(--muted); align-items:center; }
.key-legend i{ display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:4px; vertical-align:-1px; }

/* the cipher wheel */
.wheelwrap{ display:flex; flex-wrap:wrap; gap:18px; align-items:center; }
svg.wheel{ width:min(340px, 90vw); height:auto; touch-action:none; cursor:grab; user-select:none; }
svg.wheel text{ font-family:Consolas, monospace; font-weight:800; }

/* the Vigenère columns */
.vcol{ display:grid; grid-template-columns:70px 1fr 150px; gap:10px; align-items:center; border-bottom:1px solid var(--line); padding:6px 0; }
.vcol .kl{ font-family:Consolas, monospace; font-weight:800; font-size:1.4rem; color:var(--plain); text-align:center; }
.iocbars{ display:flex; align-items:flex-end; gap:4px; height:120px; border-bottom:1px solid var(--line); position:relative; padding-top:6px; }
.iocbars .ib{ flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; height:100%; font-size:.7rem; cursor:pointer; }
.iocbars .ib i{ display:block; width:70%; background:#9db4e0; border-radius:3px 3px 0 0; }
.iocbars .ib.hi i{ background:var(--navy); }
.iocbars .ib.sel i{ background:var(--red); }
.iocbars .eng{ position:absolute; left:0; right:0; border-top:2px dashed #f4a3b0; }
table.data{ border-collapse:collapse; font-size:.85rem; }
table.data th, table.data td{ border:1px solid var(--line); padding:4px 8px; text-align:center; }
table.data th{ background:var(--light); color:var(--navy); }

/* transposition grid */
.tgrid{ display:inline-grid; gap:2px; font-family:Consolas, monospace; font-weight:700; }
.tgrid .tg{ width:26px; height:26px; display:flex; align-items:center; justify-content:center; background:#f4f6fb; border-radius:3px; }
.tgrid .th{ background:var(--navy); color:#fff; border-radius:4px; cursor:pointer; font-size:.8rem; flex-direction:column; height:auto; padding:2px 0; }
.rails{ font-family:Consolas, monospace; font-weight:700; line-height:1.5; white-space:pre; overflow-x:auto; background:#f4f6fb; padding:8px; border-radius:8px; }

/* a printed message (CipherUI.sheet) */
.csheet{ --pfs:15pt; color:#000; }
.csheet .cs-t{ margin:0 0 2mm; font-size:14pt; color:#002060; }
.csheet .cs-meta{ margin:0 0 2mm; font-size:10pt; }
.csheet .cs-in{ font-size:10pt; border:1px solid #888; border-radius:6px; padding:4px 8px; margin:0 0 4mm; }
.csheet .cs-pl{ display:flex; flex-wrap:wrap; gap:calc(var(--pfs) * .35) calc(var(--pfs) * .8); font-family:Consolas, "Courier New", monospace; font-size:var(--pfs); margin-bottom:4mm; }
.csheet .cs-w{ display:inline-flex; }
.csheet .cs-c{ display:inline-flex; flex-direction:column; align-items:center; width:1.05em; }
.csheet .cs-c i{ display:block; width:.9em; height:1.55em; border-bottom:1px solid #777; }
.csheet .cs-c i.nl{ border:0; }
.csheet .cs-tb{ border-collapse:collapse; width:100%; font-family:Consolas, monospace; break-inside:avoid; }
.csheet .cs-tb td, .csheet .cs-tb th{ border:1px solid #888; text-align:center; height:7mm; font-size:9.5pt; padding:0 1px; }
.csheet.one{ width:186mm; max-width:100%; }
.csheet.one .cs-tb td, .csheet.one .cs-tb th{ height:6mm; }

/* printing: every page prints in black on white, with nothing interactive */
@media print{
  body{ background:#fff; }
  header.cc{ background:none; color:#000; padding:0 0 6px; }
  header.cc p{ color:#333; }
  main.cc{ margin:0; max-width:none; padding:0; }
  .panel{ box-shadow:none; padding:0; margin:0 0 10px; }
  .noprint, .tabs, .btn, .chip{ display:none !important; }
  .cipherbox{ background:none; color:#000; padding:0; }
  .ctext{ max-height:none; overflow:visible; }
  .ctext .cell .c{ color:#000; }
  .ctext .cell .p{ color:#000; border-bottom:1px solid #888; min-height:1.2em; }
  .ctext .cell .p.none{ color:transparent; }
}
