/* Wololoop - an Age of Empires skin for a coding pad.
 * Parchment for words, stone and timber for code, gold bevel on everything
 * that can be clicked. No image assets: every texture is a CSS gradient. */

:root {
  --parchment: #e7d8b6;
  --parchment-deep: #d8c49a;
  --parchment-shade: #c9b184;
  --ink: #33251a;
  --ink-soft: #6a553c;

  --timber: #2b2016;
  --timber-dark: #1c150e;
  --stone: #3a332a;
  --stone-dark: #241f19;

  --gold: #d9b45c;
  --gold-bright: #f3dc9a;
  --gold-dark: #8a6a2f;

  --banner-green: #46702f;
  --banner-red: #96331f;
  --amber: #c98a1b;

  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --prose: "EB Garamond", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --parchment-fill:
    radial-gradient(ellipse at 18% 8%, rgba(255, 252, 236, 0.62), transparent 58%),
    radial-gradient(ellipse at 82% 86%, rgba(150, 110, 52, 0.16), transparent 62%),
    linear-gradient(170deg, #ecdfc0, #ddc9a1 70%, #d4bd91);

  --timber-fill:
    linear-gradient(180deg, rgba(255, 220, 150, 0.05), transparent 40%),
    linear-gradient(#2f2318, #1f170f);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--timber-dark);
  color: var(--parchment);
  font-family: var(--prose);
  font-size: 15px;
}

body { display: flex; flex-direction: column; overflow: hidden; }

.spacer { flex: 1; }
.hidden { display: none !important; }

/* A gold bevel, used on every raised edge in the interface. */
.bevel,
.topbar,
.res,
.toolbar button,
.picker select,
dialog {
  border: 1px solid var(--gold-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 233, 176, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 56px;
  flex: none;
  background: var(--timber-fill);
  border-width: 0 0 3px;
  border-bottom-color: var(--gold-dark);
  position: relative;
}

/* the thin gold rule that runs under every AoE panel edge */
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}
.brand span { color: var(--parchment); }

.picker select {
  background: linear-gradient(#4a3f2f, #33291c);
  color: var(--parchment);
  border-radius: 3px;
  padding: 6px 9px;
  font-family: var(--prose);
  font-size: 14px;
  max-width: 42vw;
}

/* resource bar: parts held, tests won, sand left in the glass */

.resources { display: flex; align-items: center; gap: 8px; }

.res {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 3px;
  background: linear-gradient(#453a2a, #2b2218);
}

svg.res-icon {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}
.clock.over svg.res-icon { stroke: #e0785f; }

.res-value {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--gold-bright);
  min-width: 42px;
  text-align: right;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.clock.warn .res-value { color: #f0c674; }
.clock.over .res-value { color: #e0785f; }

.runtime {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #b8a887;
  white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber);
       box-shadow: 0 0 6px currentColor; }
.dot.ready { background: #7fb069; }
.dot.busy { background: var(--gold); animation: pulse 1s infinite; }
.dot.error { background: #c9553d; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------------------------------------------------------------- layout */

#layout { flex: 1; display: flex; min-height: 0; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.problem { width: 43%; background: var(--parchment-fill); color: var(--ink); }
.work { flex: 1; background: var(--stone-dark); }

.gutter {
  width: 8px;
  flex: none;
  cursor: col-resize;
  background: linear-gradient(90deg, #1a140d, #3a2d1d 45%, #1a140d);
  border-left: 1px solid var(--gold-dark);
  border-right: 1px solid var(--gold-dark);
}
.gutter:hover { background: linear-gradient(90deg, #2a2114, var(--gold-dark) 45%, #2a2114); }

/* ------------------------------------------------------------- problem */

.stage-tabs {
  display: flex;
  gap: 3px;
  padding: 8px 14px 0;
  flex: none;
  background: linear-gradient(180deg, rgba(120, 90, 45, 0.18), transparent);
  border-bottom: 2px solid var(--gold-dark);
}

.stage-tabs button {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: linear-gradient(#d3bc90, #c2a878);
  border: 1px solid var(--gold-dark);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 7px 15px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 244, 210, 0.5);
}
.stage-tabs button:hover { color: var(--ink); background: linear-gradient(#e0cca4, #cdb484); }
.stage-tabs button.active {
  color: var(--ink);
  background: var(--parchment-fill);
  box-shadow: inset 0 2px 0 var(--gold), inset 0 1px 0 rgba(255, 244, 210, 0.6);
}
.stage-tabs button.locked { opacity: 0.62; font-style: italic; }
.stage-tabs button.passed::after { content: " ✦"; color: var(--banner-green); }

.problem-body {
  overflow-y: auto;
  padding: 6px 30px 70px;
  line-height: 1.68;
  font-size: 16px;
}

.problem-body h2 {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 24px 0 6px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--parchment-shade);
}
.problem-body h3 {
  font-family: var(--display);
  font-size: 15px;
  margin: 22px 0 8px;
  color: var(--ink-soft);
}
.problem-body p { margin: 11px 0; }
.problem-body li { margin: 6px 0; }
.problem-body strong { color: #241a11; }

.problem-body code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(120, 90, 45, 0.15);
  border: 1px solid var(--parchment-shade);
  border-radius: 3px;
  padding: 1px 5px;
}

.problem-body pre.code {
  background: linear-gradient(#efe2c4, #e2d0aa);
  border: 1px solid var(--gold-dark);
  border-left: 4px solid var(--gold-dark);
  border-radius: 3px;
  padding: 13px 15px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255, 250, 232, 0.8);
}
.problem-body pre.code code { background: none; border: none; padding: 0; }

.problem-body blockquote {
  margin: 16px 0;
  padding: 10px 18px;
  border: 1px solid var(--gold-dark);
  border-left: 5px solid var(--gold-dark);
  border-radius: 3px;
  background: rgba(160, 125, 60, 0.13);
  color: #4a3826;
  font-style: italic;
}
.problem-body blockquote p { margin: 6px 0; }
.problem-body a { color: #7a5320; }

.locked-notice {
  text-align: center;
  margin: 52px auto 0;
  max-width: 460px;
  padding: 30px 26px;
  color: var(--ink-soft);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  background: linear-gradient(#e2d2ac, #d5c093);
  box-shadow: inset 0 1px 0 rgba(255, 250, 232, 0.7), 0 3px 10px rgba(60, 40, 15, 0.25);
}
.locked-notice strong { font-family: var(--display); font-size: 17px; color: var(--ink); }
.locked-notice button { margin-top: 16px; }

/* ---------------------------------------------------------------- work */

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  flex: none;
  background: var(--timber-fill);
  border-bottom: 2px solid var(--gold-dark);
}

button {
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-radius: 3px;
  border: 1px solid var(--gold-dark);
  background: linear-gradient(#54452f, #382c1d);
  color: var(--parchment);
  padding: 7px 14px;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}
button:hover:not(:disabled) {
  background: linear-gradient(#68573b, #443524);
  border-color: var(--gold);
}
button:active:not(:disabled) { box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55); }
button:disabled { opacity: 0.38; cursor: default; }

button.primary {
  background: linear-gradient(#e0bb63, #a8801f);
  color: #2b1f08;
  border-color: var(--gold-bright);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
}
button.primary:hover:not(:disabled) { background: linear-gradient(#f0cf7e, #bb9128); }

button.accent {
  background: linear-gradient(#5a8a3c, #355924);
  color: #f2fbe8;
  border-color: #7fb069;
}
button.accent:hover:not(:disabled) { background: linear-gradient(#6c9e48, #3f682a); }

button.ghost {
  background: linear-gradient(#3e3527, #2a2318);
  color: #c3b28e;
}
button.small { padding: 4px 9px; font-size: 11px; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  opacity: 0.7;
  margin-left: 6px;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 3px;
}

.editor-host {
  flex: 1 1 55%;
  min-height: 120px;
  overflow: hidden;
  position: relative;
  border-bottom: 2px solid var(--gold-dark);
}
.CodeMirror { height: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
#editor {
  width: 100%; height: 100%;
  background: var(--stone-dark);
  color: var(--parchment);
  border: none; outline: none; resize: none;
  padding: 10px 12px;
  font-family: var(--mono); font-size: 13px; line-height: 1.55;
}

.results-pane {
  flex: 1 1 45%;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(#2c251c, #221c15);
}

.out-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  flex: none;
  border-bottom: 1px solid var(--gold-dark);
  background: linear-gradient(rgba(120, 90, 45, 0.22), transparent);
}
.out-tabs button {
  background: none;
  border: 1px solid transparent;
  color: #a89774;
  padding: 5px 12px;
  font-size: 12px;
  text-shadow: none;
}
.out-tabs button.active {
  color: var(--gold-bright);
  border-color: var(--gold-dark);
  background: linear-gradient(#463a28, #2e2619);
}
.tally { font-family: var(--mono); font-size: 11px; margin-left: 4px; }
.tally.good { color: #9ccb7a; }
.tally.bad { color: #e0785f; }

.console {
  flex: 1;
  margin: 0;
  padding: 12px 16px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #ddd0b4;
}
.console .err { color: #e0785f; }
.console .meta { color: #978a68; }

.tests { flex: 1; overflow: auto; padding: 10px 12px; }

/* React preview: the app renders in a sandboxed iframe, framed like an in-game window */
.preview { flex: 1; display: flex; padding: 10px 12px; min-height: 0; }
.preview:empty::before {
  content: "Run (Ctrl+Enter) renders your preview() here.";
  margin: auto;
  color: #978a68;
  font-style: italic;
}
.preview-frame {
  flex: 1;
  width: 100%;
  border: 2px solid var(--gold-dark);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 0 1px #16110b;
  background: #fff;
}

.stage-group { margin-bottom: 18px; }
.stage-group h4 {
  font-family: var(--display);
  margin: 8px 2px 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid rgba(217, 180, 92, 0.3);
  padding-bottom: 5px;
}

.test-row {
  display: flex;
  gap: 11px;
  align-items: baseline;
  padding: 6px 11px;
  border-radius: 3px;
  border-left: 3px solid transparent;
}
.test-row + .test-row { margin-top: 2px; }
.test-row .mark { font-family: var(--mono); font-size: 12px; width: 15px; flex: none; }
.test-row .name { flex: 1; font-size: 14px; }

.test-row.pass { color: #9d9177; border-left-color: var(--banner-green); }
.test-row.pass .mark { color: #7fb069; }
.test-row.fail, .test-row.error {
  background: rgba(150, 51, 31, 0.16);
  border-left-color: var(--banner-red);
  color: #eddfc5;
}
.test-row.fail .mark, .test-row.error .mark { color: #e0785f; }
.test-row.todo { color: #a89774; border-left-color: var(--amber); }
.test-row.todo .mark { color: var(--amber); }

.test-row pre {
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: #e4d7bb;
  white-space: pre-wrap;
  opacity: 0.92;
}

/* ----------------------------------------------------------- system design */

/* Mocks swap the editor for the design pane; study modules drop the right side
 * entirely and read like a book. */
.design-pane { display: none; flex: 1; background: var(--stone-dark); }
.mode-design .work { display: none; }
.mode-mock .design-pane { display: flex; }
.mode-study .gutter { display: none; }
.mode-study .problem { width: 100% !important; }
.mode-study .problem-body { width: 100%; max-width: 860px; margin: 0 auto; padding: 10px 40px 90px; font-size: 17px; }
.mode-study .stage-tabs { justify-content: center; flex-wrap: wrap; }

a.linkbtn {
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-radius: 3px;
  border: 1px solid var(--gold-bright);
  padding: 7px 14px;
  text-decoration: none;
  background: linear-gradient(#e0bb63, #a8801f);
  color: #2b1f08;
  box-shadow: inset 0 1px 0 rgba(255, 233, 176, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.45);
}
a.linkbtn:hover { background: linear-gradient(#f0cf7e, #bb9128); }

.dtab { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.pm-card {
  flex: none;
  margin: 12px 12px 0;
  padding: 10px 14px;
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  background: linear-gradient(#3b3125, #2b2319);
}
.pm-name { font-family: var(--display); font-weight: 700; color: var(--gold-bright); font-size: 14px; }
.pm-name span { font-family: var(--prose); font-weight: 400; color: #b8a887; margin-left: 8px; font-style: italic; }
.pm-intro { margin: 4px 0 0; color: #d9cba9; font-size: 14px; line-height: 1.5; }

.pm-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pm-empty { color: #978a68; font-style: italic; margin: auto; max-width: 420px; text-align: center; line-height: 1.55; }
.pm-q {
  align-self: flex-end;
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 3px;
  background: linear-gradient(#5a4a30, #45381f);
  border: 1px solid var(--gold-dark);
  color: var(--parchment);
  font-size: 14.5px;
}
.pm-a {
  align-self: flex-start;
  max-width: 92%;
  padding: 4px 14px;
  border-radius: 3px;
  background: var(--parchment-fill);
  color: var(--ink);
  border: 1px solid var(--gold-dark);
  font-size: 15px;
  line-height: 1.55;
}
.pm-a p { margin: 7px 0; }
.pm-a ul, .pm-a ol { margin: 6px 0; padding-left: 20px; }
.pm-a code { font-family: var(--mono); font-size: 12px; }
.pm-chip {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--parchment-shade);
}

.pm-ask { flex: none; display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--gold-dark);
          background: var(--timber-fill); }
.pm-ask input {
  flex: 1;
  font-family: var(--prose);
  font-size: 15px;
  padding: 7px 10px;
  color: var(--parchment);
  background: #1c160f;
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  outline: none;
}
.pm-ask input:focus { border-color: var(--gold); }

#design-notes {
  flex: 1;
  margin: 0;
  padding: 14px 16px;
  border: none;
  outline: none;
  resize: none;
  background: var(--stone-dark);
  color: var(--parchment);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

.checkpoint { flex: 1; overflow-y: auto; padding: 12px 18px 30px; color: #e4d7bb; }
.cp-head { font-family: var(--display); color: var(--gold); letter-spacing: 0.06em; margin: 6px 0 4px; font-size: 14px; }
.cp-lead { color: #b8a887; font-style: italic; margin: 0 0 12px; }
.cp-item { display: flex; gap: 10px; align-items: baseline; padding: 6px 4px; cursor: pointer; line-height: 1.5; }
.cp-item input { accent-color: var(--gold); transform: translateY(2px); }
.cp-item code { font-family: var(--mono); font-size: 12px; }
.checkpoint > button { margin-top: 14px; }
.debrief {
  margin-top: 22px;
  padding: 4px 16px 10px;
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  background: var(--parchment-fill);
  color: var(--ink);
}
.debrief h4 { font-family: var(--display); margin: 10px 0 4px; }

/* prose extras: tables, folded answers, rules */
.table-wrap { overflow-x: auto; margin: 14px 0; }
.problem-body table, .debrief table, .pm-a table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.45; }
.problem-body th, .problem-body td, .pm-a th, .pm-a td {
  border: 1px solid var(--parchment-shade);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.problem-body th, .pm-a th { font-family: var(--display); font-size: 12.5px; background: rgba(120, 90, 45, 0.16); }
.problem-body hr { border: none; height: 2px; margin: 26px 0;
                   background: linear-gradient(90deg, transparent, var(--gold-dark), transparent); }

details.reveal {
  margin: 12px 0;
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  background: rgba(160, 125, 60, 0.1);
  padding: 0 14px;
}
details.reveal > summary {
  cursor: pointer;
  padding: 8px 0;
  font-family: var(--display);
  font-size: 13.5px;
  color: var(--ink-soft);
}
details.reveal[open] > summary { border-bottom: 1px solid var(--parchment-shade); margin-bottom: 4px; }

dialog .modal-md { max-height: 66vh; overflow-y: auto; padding: 0 8px 20px; font-size: 16px; }

/* ---------------------------------------------------------------- misc */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 13px 26px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #2b1f08;
  background: linear-gradient(#f0d894, #d4ac52);
  border: 2px solid var(--gold-dark);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 250, 225, 0.75), 0 8px 26px rgba(0, 0, 0, 0.6);
}

dialog {
  background: var(--parchment-fill);
  color: var(--ink);
  border-width: 3px;
  border-radius: 4px;
  max-width: min(880px, 92vw);
  width: 880px;
  padding: 18px 20px;
}
dialog::backdrop { background: rgba(20, 12, 4, 0.72); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-family: var(--display);
  font-size: 17px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--parchment-shade);
}
.warn { color: #8a4a1c; font-size: 13px; margin: 0 0 12px; font-style: italic; }
dialog pre.code {
  background: linear-gradient(#efe2c4, #e2d0aa);
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  padding: 13px 15px;
  max-height: 62vh;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #1d1710; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(#5a4a30, #3a2f1e);
  border: 1px solid var(--gold-dark);
  border-radius: 2px;
}
.problem-body::-webkit-scrollbar-track { background: var(--parchment-shade); }

@media (max-width: 900px) {
  #layout { flex-direction: column; }
  .problem { width: auto; height: 42%; }
  .gutter { display: none; }
  .mode-study .problem { height: auto; flex: 1; }
  .mode-study .problem-body { padding: 8px 16px 60px; }
  .resources { gap: 5px; }
  .res { padding: 4px 8px; }
  .runtime { display: none; }
}
