/* Lickrick MUD: a dark, lamp-lit table for the game text (the stock world is
   written for bright colours on a dark screen) and a handbook beside it. */

@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("fonts/atkinson-hyperlegible-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("fonts/alegreya-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("fonts/alegreya-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("fonts/alegreya-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --hearth: #1c1714;   /* page */
  --table: #241e1a;    /* game text surface */
  --board: #2e2621;    /* raised: handbook, controls */
  --seam: #43382f;     /* lines between surfaces */
  --vellum: #e6dccb;   /* text */
  --ash: #a39685;      /* quiet text */
  --lamp: #f0a93b;     /* lit exits, focus */
  --lamp-ink: #2a1c05; /* text on lamp */
  --verdigris: #7fbfae;/* what you typed, commands you can click */

  /* The 16 terminal colours, tuned to sit on the warm dark surface. */
  --a0: #5b5047;  --a1: #d9634f;  --a2: #8fb65a;  --a3: #d9a441;
  --a4: #6c9bd1;  --a5: #b98ac9;  --a6: #6fbfb8;  --a7: #d8cfc0;
  --a8: #8a7d70;  --a9: #f08672;  --a10: #b4d977; --a11: #f4cc6a;
  --a12: #94bcf0; --a13: #d6aae6; --a14: #98dcd4; --a15: #fff6e6;

  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --book: "Alegreya", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--hearth);
  color: var(--vellum);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; }

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

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "bar side" "world side";
}

/* ---------- top bar ---------- */

.bar {
  grid-area: bar;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 1.25rem 0.55rem;
  border-bottom: 1px solid var(--seam);
}

.wordmark {
  margin: 0 auto 0 0;
  font-family: var(--book);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ash);
  font-size: 0.87rem;
}
.status-dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--ash);
}
.status[data-state="open"] .status-dot { background: var(--a10); }
.status[data-state="closed"] .status-dot { background: var(--a1); }

.quiet-button {
  background: none;
  border: 1px solid var(--seam);
  border-radius: 6px;
  padding: 0.2rem 0.7rem;
  font-size: 0.87rem;
}
.quiet-button:hover { border-color: var(--ash); }
#reconnect { border-color: var(--lamp); color: var(--lamp); }

.guide-toggle { display: none; }

/* ---------- the game ---------- */

.world {
  grid-area: world;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--table);
}

.log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.25rem 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 8;
  scrollbar-color: var(--seam) transparent;
}
.log:focus-visible { outline-offset: -2px; }

.line { min-height: 1.45em; }

.f0 { color: var(--a0); }  .f1 { color: var(--a1); }  .f2 { color: var(--a2); }  .f3 { color: var(--a3); }
.f4 { color: var(--a4); }  .f5 { color: var(--a5); }  .f6 { color: var(--a6); }  .f7 { color: var(--a7); }
.f8 { color: var(--a8); }  .f9 { color: var(--a9); }  .f10 { color: var(--a10); } .f11 { color: var(--a11); }
.f12 { color: var(--a12); } .f13 { color: var(--a13); } .f14 { color: var(--a14); } .f15 { color: var(--a15); }
.b0 { background: var(--a0); }  .b1 { background: var(--a1); }  .b2 { background: var(--a2); }  .b3 { background: var(--a3); }
.b4 { background: var(--a4); }  .b5 { background: var(--a5); }  .b6 { background: var(--a6); }  .b7 { background: var(--a7); }
.bright { color: var(--a15); }
.underline { text-decoration: underline; }

.you { color: var(--verdigris); }
.note { color: var(--ash); font-style: italic; }

.jump {
  position: absolute;
  right: 1.25rem;
  bottom: 4.4rem;
  background: var(--lamp);
  color: var(--lamp-ink);
  border: 0;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.87rem;
  font-weight: 700;
}

.entry {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem 0.8rem;
  border-top: 1px solid var(--seam);
}
.prompt-mark { color: var(--lamp); font-weight: 700; }
.input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--hearth);
  color: var(--vellum);
  border: 1px solid var(--seam);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 16px; /* below 16px phones zoom the page on focus */
}
.input::placeholder { color: var(--ash); opacity: 0.8; }
.input:focus { outline: none; border-color: var(--lamp); }
.send {
  background: var(--board);
  border: 1px solid var(--seam);
  border-radius: 6px;
  padding: 0.55rem 1rem;
}
.send:hover { border-color: var(--ash); }

/* ---------- direction buttons (compass and the phone move bar) ---------- */

.dir {
  background: transparent;
  border: 1px solid var(--seam);
  border-radius: 8px;
  color: var(--ash);
  font-weight: 700;
  min-height: 2.6rem;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.dir:hover { border-color: var(--ash); color: var(--vellum); }
.dir:active { transform: translateY(1px); }
.dir.is-open {
  background: var(--lamp);
  border-color: var(--lamp);
  color: var(--lamp-ink);
}
.dir.is-door {
  border-color: var(--lamp);
  border-style: dashed;
  color: var(--lamp);
}
.dir-look { color: var(--vellum); font-weight: 400; }

.movebar { display: none; }
.side-head { display: none; }

/* ---------- side: compass and handbook ---------- */

.side {
  grid-area: side;
  min-height: 0;
  overflow-y: auto;
  background: var(--board);
  border-left: 1px solid var(--seam);
  scrollbar-color: var(--seam) transparent;
}

.compass {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--seam);
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  column-gap: 1.25rem;
}
.rose {
  display: grid;
  grid-template-columns: repeat(3, 3.4rem);
  grid-template-rows: repeat(3, 3.4rem);
  gap: 0.35rem;
}
.rose .dir { border-radius: 50%; font-size: 1.05rem; }
.rose-n { grid-area: 1 / 2; }
.rose-w { grid-area: 2 / 1; }
.rose-c { grid-area: 2 / 2; font-size: 0.87rem; }
.rose-e { grid-area: 2 / 3; }
.rose-s { grid-area: 3 / 2; }
.stairs { display: grid; gap: 0.35rem; }
.stairs .dir { width: 4.2rem; font-size: 0.87rem; }
.compass-note {
  grid-column: 1 / -1;
  margin: 0.9rem 0 0;
  font-family: var(--book);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--ash);
  text-align: center;
}

.guide {
  padding: 1.25rem 1.5rem 2rem;
  font-family: var(--book);
  font-size: 1.1rem;
  line-height: 1.5;
}
.guide h2 {
  margin: 0 0 0.5rem;
  font-size: 1.55rem;
  line-height: 1.15;
  font-weight: 700;
}
.guide h3 {
  margin: 1.4rem 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  font-style: italic;
  color: var(--lamp);
}
.guide p { margin: 0 0 0.6rem; }
.guide-foot { margin-top: 1.5rem; color: var(--ash); font-style: italic; font-size: 1rem; }

.cmd, kbd {
  font-family: var(--mono);
  font-size: 0.8em;
  line-height: 1.2;
  border-radius: 4px;
  padding: 0.08em 0.4em;
  white-space: nowrap;
}
.cmd {
  background: var(--hearth);
  border: 1px solid var(--seam);
  color: var(--verdigris);
}
.cmd:hover { border-color: var(--verdigris); }
kbd { border: 1px solid var(--seam); color: var(--vellum); }

/* ---------- narrow screens: the handbook becomes a drawer ---------- */

@media (max-width: 860px) {
  body { font-size: 14px; }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "bar" "world";
  }
  .bar { padding: 0.55rem 0.8rem 0.45rem; gap: 0.6rem; }
  .wordmark { font-size: 1.35rem; }
  .guide-toggle { display: inline-block; }

  .log { padding: 0.75rem 0.8rem 0.5rem; }
  .entry { padding: 0.5rem 0.8rem 0.65rem; }
  .send { display: none; }
  .jump { right: 0.8rem; bottom: 7.6rem; }

  .movebar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.3rem;
    padding: 0.5rem 0.8rem 0;
    border-top: 1px solid var(--seam);
  }
  .movebar .dir { font-size: 0.87rem; padding: 0; }

  .side {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(22rem, 92vw);
    z-index: 5;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 180ms ease, visibility 180ms;
    box-shadow: -18px 0 40px rgb(0 0 0 / 0.45);
  }
  .app.guide-open .side { transform: none; visibility: visible; }
  .side .compass { display: none; }
  .side-head {
    display: flex;
    justify-content: flex-end;
    position: sticky;
    top: 0;
    padding: 0.55rem 0.8rem;
    background: var(--board);
    border-bottom: 1px solid var(--seam);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
