/* TIFE 3.0 reference theme - "Jetan"
 *
 * The board of Martian chess is one hundred squares, orange and black. That
 * board is the whole visual system here: the map is a real jetan field, the
 * accents are the two colours of the squares, and nothing else is decorated.
 */

:root {
  --night: #0b0d12;
  --basalt: #141821;
  --rule: #262c39;
  --parchment: #ece5d5;
  --parchment-dim: #a7a394;
  --jetan-orange: #d4761a;
  --jetan-black: #1b1f2a;
  --jade: #5f9e8f;
  --alarm: #c2503f;

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --utility: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --measure: 68ch;
  --gap: 1.25rem;
  --radius: 2px;
  --text-scale: 1;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--night);
  color: var(--parchment);
  font-family: var(--body);
  font-size: calc(1.0625rem * var(--text-scale));
  line-height: 1.62;
  -webkit-text-size-adjust: 100%;
}

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

:focus-visible {
  outline: 2px solid var(--jetan-orange);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 0.5rem; top: -3rem; z-index: 50;
  background: var(--jetan-orange); color: var(--night);
  padding: 0.5rem 0.9rem; border-radius: var(--radius);
  transition: top 120ms ease;
}
.skip-link:focus { top: 0.5rem; }

/* ------------------------------------------------------------------ cover */

.cover {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: clamp(1.5rem, 5vw, 4rem);
  background:
    radial-gradient(120% 90% at 50% 0%, #1a1410 0%, var(--night) 62%);
}

.cover__inner {
  align-self: center;
  max-width: 46rem;
  margin: 0 auto;
  text-align: center;
}

.cover__board {
  width: min(230px, 46vw);
  height: min(230px, 46vw);
  margin: 0 auto 2rem;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  border: 1px solid var(--rule);
}
.cover__board i { display: block; }
.cover__board i.o { background: var(--jetan-orange); opacity: 0.82; }
.cover__board i.b { background: var(--jetan-black); }
.cover__board i.piece { position: relative; }
.cover__board i.piece::after {
  content: ""; position: absolute; inset: 22%;
  border-radius: 50%; background: var(--parchment); opacity: 0.9;
}

.cover__eyebrow {
  font-family: var(--utility);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--jetan-orange);
  margin: 0 0 0.9rem;
}

.cover__title {
  font-family: var(--display);
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1.06;
  font-weight: 400;
  margin: 0 0 0.6rem;
}

.cover__byline {
  color: var(--parchment-dim);
  font-style: italic;
  margin: 0 0 1.8rem;
}

.cover__blurb {
  max-width: 34rem;
  margin: 0 auto 2.2rem;
  color: var(--parchment-dim);
}

.cover__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.cover__foot {
  text-align: center;
  color: var(--parchment-dim);
  font-family: var(--utility);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  background: transparent;
  color: var(--parchment);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.62rem 1.05rem;
  cursor: pointer;
  min-height: 44px;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.btn:hover { border-color: var(--jetan-orange); }
.btn[aria-pressed="true"] { border-color: var(--jade); color: var(--jade); }
.btn--primary {
  background: var(--jetan-orange);
  border-color: var(--jetan-orange);
  color: #17120c;
  font-weight: 600;
}
.btn--primary:hover { background: #e08526; border-color: #e08526; }
.btn--small { padding: 0.4rem 0.7rem; min-height: 38px; font-size: 0.86em; }

/* ----------------------------------------------------------------- shell */

.shell { display: none; min-height: 100vh; flex-direction: column; }
.shell.is-live { display: flex; }

.topbar {
  display: flex;
  align-items: baseline;
  gap: var(--gap);
  flex-wrap: wrap;
  padding: 0.7rem clamp(0.9rem, 3vw, 2rem);
  border-bottom: 1px solid var(--rule);
  background: var(--basalt);
}
.topbar__title {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0;
  font-weight: 400;
}
.topbar__stats {
  font-family: var(--utility);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--parchment-dim);
  margin-left: auto;
  display: flex;
  gap: 1.1rem;
}
.topbar__stats b { color: var(--parchment); font-weight: 600; }

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: 0;
  align-items: stretch;
}

.column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(0.9rem, 3vw, 1.8rem);
}

/* ------------------------------------------------------------- transcript */

.transcript {
  flex: 1;
  overflow-y: auto;
  max-width: var(--measure);
  width: 100%;
  margin: 0 auto;
  padding-right: 0.5rem;
}

.msg { margin: 0 0 1rem; white-space: pre-wrap; }

.msg--command {
  font-family: var(--utility);
  color: var(--jetan-orange);
  font-size: 0.88em;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}
.msg--command::before { content: "> "; }

.msg--room { margin-bottom: 1rem; }
.msg--room .room-title {
  display: block;
  font-family: var(--utility);
  font-size: 0.76rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--jetan-orange);
  margin-bottom: 0.5rem;
}

.msg--story { }
.msg--action { color: var(--parchment); }
.msg--speech { border-left: 2px solid var(--rule); padding-left: 0.9rem; }
.msg--notice {
  font-family: var(--utility);
  font-size: 0.82em;
  color: var(--jade);
  letter-spacing: 0.02em;
}
.msg--error { color: var(--alarm); }
.msg--ending {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
  font-style: italic;
}

/* ------------------------------------------------------------ command bar */

.entry {
  border-top: 1px solid var(--rule);
  padding-top: 0.9rem;
  margin-top: 0.5rem;
  max-width: var(--measure);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.entry__row { display: flex; gap: 0.5rem; align-items: center; }

.entry__prompt {
  font-family: var(--utility);
  color: var(--jetan-orange);
  user-select: none;
}

.entry__input {
  flex: 1;
  background: var(--basalt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.62rem 0.8rem;
  font-family: var(--utility);
  min-height: 44px;
}
.entry__input:focus { border-color: var(--jetan-orange); outline: none; }

.verbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.verbs__group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.verbs__label {
  font-family: var(--utility);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  align-self: center;
  margin-right: 0.2rem;
}

/* ------------------------------------------------------------------- rail */

.rail {
  border-left: 1px solid var(--rule);
  background: var(--basalt);
  overflow-y: auto;
}

.panel { border-bottom: 1px solid var(--rule); }
.panel__head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 0;
  padding: 0.75rem clamp(0.8rem, 2vw, 1.1rem);
  cursor: pointer;
  font-family: var(--utility);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  min-height: 44px;
}
.panel__head:hover { color: var(--parchment); }
.panel__head[aria-expanded="true"] { color: var(--jetan-orange); }
.panel__head .chev { transition: transform 140ms ease; }
.panel__head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.panel__body {
  padding: 0 clamp(0.8rem, 2vw, 1.1rem) 1rem;
  font-size: 0.94em;
}
.panel__body[hidden] { display: none; }
.panel__body ul { margin: 0; padding-left: 1.1rem; }
.panel__body li { margin-bottom: 0.4rem; }
.panel__body .empty { color: var(--parchment-dim); font-style: italic; }
.panel__body .done { color: var(--jade); }
.panel__body .done::before { content: "\2713\00a0"; }
.panel__body .locked { color: var(--parchment-dim); }

/* ------------------------------------------------------- the jetan map */

.jetan {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-bottom: 0.7rem;
}
.jetan__sq {
  aspect-ratio: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--utility);
  font-size: 0.52rem;
  color: transparent;
}
.jetan__sq.o { background: color-mix(in srgb, var(--jetan-orange) 34%, var(--basalt)); }
.jetan__sq.b { background: var(--jetan-black); }
.jetan__sq.room { color: var(--parchment-dim); }
.jetan__sq.room::after {
  content: ""; position: absolute; inset: 26%;
  border: 1px solid var(--parchment-dim); border-radius: 50%;
}
.jetan__sq.visited::after { background: var(--parchment-dim); }
.jetan__sq.here { color: var(--night); }
.jetan__sq.here::after {
  background: var(--jetan-orange);
  border-color: var(--jetan-orange);
  inset: 18%;
}
.jetan__sq.lethal { box-shadow: inset 0 0 0 1px var(--alarm); }

.legend {
  font-size: 0.78em;
  color: var(--parchment-dim);
  line-height: 1.5;
}
.legend b { color: var(--parchment); font-weight: 600; }

/* --------------------------------------------------------------- settings */

.field { margin-bottom: 0.9rem; }
.field label {
  display: block;
  font-family: var(--utility);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  margin-bottom: 0.3rem;
}
.field select, .field input[type="range"] {
  width: 100%;
  background: var(--night);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem;
  min-height: 44px;
}
.field .check { display: flex; align-items: center; gap: 0.55rem; min-height: 44px; }
.field .check input { width: 1.1rem; height: 1.1rem; accent-color: var(--jetan-orange); }
.field .check label { text-transform: none; letter-spacing: 0; font-family: var(--body);
  font-size: 0.94rem; color: var(--parchment); margin: 0; }

.caption-bar {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: var(--jetan-black);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  font-family: var(--utility);
  font-size: 0.8rem;
  color: var(--jade);
  max-width: 90vw;
  z-index: 30;
}
.caption-bar[hidden] { display: none; }

/* ------------------------------------------------------- profile variants */

body[data-profile="low_vision"] {
  --text-scale: 1.3;
  --parchment: #fff8ea;
  --parchment-dim: #d8d2c2;
  --rule: #4a5468;
}
body[data-profile="low_vision"] .btn { border-width: 2px; }

body[data-profile="screen_reader"] .main { grid-template-columns: minmax(0, 1fr); }
body[data-profile="screen_reader"] .rail { border-left: 0; border-top: 1px solid var(--rule); }
body[data-profile="screen_reader"] .jetan { display: none; }

body[data-profile="motor"] .btn { min-height: 52px; padding: 0.8rem 1.2rem; }
body[data-profile="motor"] .entry__input { min-height: 52px; }

body[data-profile="cognitive"] .verbs__group--extra { display: none; }
body[data-profile="cognitive"] .msg { margin-bottom: 1.35rem; }

body[data-captions="off"] .caption-bar { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
body[data-motion="reduced"] * { animation: none !important; transition: none !important; }

/* ---------------------------------------------------------------- narrow */

@media (max-width: 62rem) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .rail { border-left: 0; border-top: 1px solid var(--rule); }
  .topbar__stats { margin-left: 0; width: 100%; }
}
