/* ORTUS — "dawn over dark". The trilogy lives in the dark; ORTUS is the first
   light inside it. Young Serif (display) · Newsreader (body) · IBM Plex Mono (voice). */
@import url('../fonts/ortus-fonts.css');

:root {
  --ink: #f3ead8;
  --ink-soft: #cdc3b2;
  --ink-faint: #8b8578;
  --night: #06070f;
  --night-2: #0b0e1c;
  --gold: #f2c78a;
  --gold-deep: #d9a15e;
  --rose: #e9a58c;
  --line: rgba(243, 234, 216, 0.14);
  --panel: rgba(10, 12, 22, 0.86);
  --panel-line: rgba(243, 234, 216, 0.12);
  --display: 'Young Serif', Georgia, serif;
  --body: 'Newsreader', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { position: fixed; inset: 0; }

canvas#world {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none;
  cursor: default;
}
canvas#world.targeting { cursor: crosshair; }

/* ---- The instrument voice --------------------------------------------- */
#voice {
  position: fixed; left: 50%; bottom: 16vh; transform: translateX(-50%) translateY(8px);
  max-width: min(680px, 88vw); text-align: center;
  font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.02em;
  color: var(--ink-soft); opacity: 0; pointer-events: none;
  transition: opacity 1.2s ease, transform 1.2s ease; z-index: 40;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
}
#voice.speaking { opacity: 0.92; transform: translateX(-50%) translateY(0); }

/* ---- HUD (thin bottom bar) -------------------------------------------- */
#hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 1.2rem;
  padding: 0.7rem clamp(0.8rem, 3vw, 2rem);
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(4, 5, 12, 0.82), rgba(4, 5, 12, 0));
  opacity: 0; transform: translateY(12px); transition: opacity 1s ease, transform 1s ease;
  pointer-events: none;
}
#hud.shown { opacity: 1; transform: none; pointer-events: auto; }

.hud-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
#hud-date { font-family: var(--mono); font-size: 0.82rem; color: var(--ink); letter-spacing: 0.02em; }
#hud-weather { font-size: 0.9rem; color: var(--ink-soft); font-style: italic; }

.hud-dew { display: flex; align-items: center; gap: 4px; }
.hud-dew .dew {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(243, 234, 216, 0.12); border: 1px solid rgba(243, 234, 216, 0.16);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}
.hud-dew .dew.on {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(242, 199, 138, 0.7);
  border-color: transparent;
}
.hud-dew::before { content: 'dew'; font-family: var(--mono); font-size: 0.66rem; color: var(--ink-faint); margin-right: 4px; text-transform: uppercase; letter-spacing: 0.1em; }

.hud-spacer { flex: 1; }

.toolbar { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }
.tool {
  appearance: none; background: rgba(243, 234, 216, 0.04);
  border: 1px solid var(--line); color: var(--ink-soft);
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.04em;
  padding: 0.42rem 0.7rem; border-radius: 999px; cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  min-height: 44px; min-width: 44px; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
}
.tool:hover { background: rgba(243, 234, 216, 0.1); color: var(--ink); border-color: rgba(243, 234, 216, 0.3); }
.tool:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tool.on { color: var(--gold); border-color: var(--gold-deep); }
.tool.urgent::after {
  content: attr(data-n); position: absolute; top: -6px; right: -6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--gold); color: #201406; font-size: 0.62rem; line-height: 16px;
  text-align: center; font-family: var(--mono); box-shadow: 0 0 8px rgba(242, 199, 138, 0.6);
}

/* ---- Ceremony ---------------------------------------------------------- */
.ceremony {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6rem; padding: 2rem 1.2rem; text-align: center;
  background: radial-gradient(120% 90% at 50% 45%, #0d1024 0%, #06070f 70%);
  opacity: 0; transition: opacity 1.4s ease;
  overflow-y: auto;
}
.ceremony.in { opacity: 1; }
.ceremony.out { opacity: 0; transition: opacity 1.2s ease; }
.ceremony.kindling .ember { transform: scale(2.4); box-shadow: 0 0 120px 40px rgba(242, 199, 138, 0.5); }

.ember {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle, #fff2d6 0%, var(--gold) 40%, var(--gold-deep) 70%, transparent 100%);
  box-shadow: 0 0 40px 10px rgba(242, 199, 138, 0.5);
  animation: emberBreath 4s ease-in-out infinite; margin-bottom: 0.8rem;
  transition: transform 1.6s ease, box-shadow 1.6s ease;
}
@keyframes emberBreath { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.2); opacity: 1; } }

.ortus-title {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 5rem); letter-spacing: 0.14em;
  margin: 0; color: var(--ink);
  text-shadow: 0 0 40px rgba(242, 199, 138, 0.25);
}
.ceremony-sub { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold-deep); margin: 0 0 0.6rem; }
.ceremony-line { font-family: var(--body); font-size: 1.05rem; font-style: italic; color: var(--ink-soft); max-width: 34rem; line-height: 1.6; margin: 0 0 1rem; }

.ceremony-steps { display: flex; flex-direction: column; gap: 1.3rem; width: min(46rem, 92vw); }
.ceremony-prompt { font-family: var(--display); font-size: 1.15rem; color: var(--ink); margin: 0 0 0.5rem; }
.ceremony-opts { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.ceremony-opt {
  flex: 1 1 9rem; min-width: 8rem; max-width: 13rem;
  display: flex; flex-direction: column; gap: 0.25rem; align-items: center;
  background: rgba(243, 234, 216, 0.03); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.8rem 0.7rem; cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
  color: var(--ink);
}
.ceremony-opt:hover { border-color: rgba(242, 199, 138, 0.45); transform: translateY(-2px); }
.ceremony-opt.sel { border-color: var(--gold); background: rgba(242, 199, 138, 0.1); box-shadow: 0 0 20px rgba(242, 199, 138, 0.18); }
.ceremony-opt:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.opt-label { font-family: var(--display); font-size: 1.05rem; }
.opt-line { font-family: var(--body); font-style: italic; font-size: 0.82rem; color: var(--ink-faint); line-height: 1.35; }

.ceremony-confirm {
  margin-top: 1.6rem; background: var(--gold); color: #1c1206;
  border: none; border-radius: 999px; padding: 0.8rem 2rem;
  font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.06em; cursor: pointer;
  transition: opacity 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: 0 0 30px rgba(242, 199, 138, 0.3);
}
.ceremony-confirm[disabled] { opacity: 0.3; cursor: default; box-shadow: none; }
.ceremony-confirm:not([disabled]):hover { transform: translateY(-2px); box-shadow: 0 0 40px rgba(242, 199, 138, 0.5); }

/* ---- Skip / first day -------------------------------------------------- */
.skip {
  position: fixed; right: clamp(0.8rem, 3vw, 2rem); top: clamp(0.8rem, 3vw, 1.6rem); z-index: 50;
  background: rgba(10, 12, 22, 0.7); border: 1px solid var(--line); color: var(--ink-soft);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em;
  padding: 0.45rem 0.8rem; border-radius: 999px; cursor: pointer;
}
.skip:hover { color: var(--ink); border-color: rgba(243, 234, 216, 0.3); }

/* ---- Dum aberas -------------------------------------------------------- */
.dum-aberas {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -46%);
  z-index: 80; width: min(38rem, 92vw); max-height: 82vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px;
  padding: 1.8rem clamp(1.2rem, 4vw, 2.2rem);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 60px rgba(242, 199, 138, 0.08);
  opacity: 0; transition: opacity 0.9s ease, transform 0.9s ease;
  backdrop-filter: blur(8px);
}
.dum-aberas.in { opacity: 1; transform: translate(-50%, -50%); }
.dum-aberas.out { opacity: 0; transform: translate(-50%, -54%); }
.dum-head { font-family: var(--display); font-size: 1.8rem; margin: 0; color: var(--gold); letter-spacing: 0.04em; }
.dum-sub { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin: 0.2rem 0 1.3rem; }
.dum-lines { display: flex; flex-direction: column; gap: 0.9rem; margin-bottom: 1.6rem; }
.dum-line { font-family: var(--body); font-size: 1.08rem; line-height: 1.55; color: var(--ink); margin: 0; padding-left: 1rem; border-left: 2px solid rgba(242, 199, 138, 0.3); }
.dum-close {
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.05em;
  padding: 0.6rem 1.4rem; border-radius: 999px; cursor: pointer;
}
.dum-close:hover { color: var(--ink); border-color: var(--gold-deep); background: rgba(242, 199, 138, 0.06); }

/* ---- Time-lapse veil --------------------------------------------------- */
.timelapse-veil {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 22vh; pointer-events: none; opacity: 0; transition: opacity 0.8s ease;
}
.timelapse-veil.in { opacity: 1; }
.tl-word { font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.1em; color: var(--ink-soft); text-shadow: 0 2px 20px #000; }

/* ---- Modals ------------------------------------------------------------ */
.modal-veil {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 5, 12, 0.6); backdrop-filter: blur(4px); padding: 1.2rem;
}
.modal {
  width: min(34rem, 94vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px;
  padding: 1.6rem clamp(1.1rem, 4vw, 2rem); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.modal-head { font-family: var(--display); font-size: 1.5rem; margin: 0 0 0.2rem; color: var(--ink); }
.modal-sub { font-family: var(--body); font-style: italic; color: var(--ink-soft); margin: 0 0 1.2rem; line-height: 1.5; }
.modal-row { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.2rem; }
.modal .primary { background: var(--gold); color: #1c1206; border: none; border-radius: 999px; padding: 0.6rem 1.4rem; font-family: var(--mono); font-size: 0.78rem; cursor: pointer; }
.modal .primary:hover { box-shadow: 0 0 24px rgba(242, 199, 138, 0.4); }
.modal .ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); border-radius: 999px; padding: 0.6rem 1.2rem; font-family: var(--mono); font-size: 0.78rem; cursor: pointer; }
.modal .ghost:hover { color: var(--ink); border-color: rgba(243, 234, 216, 0.3); }
.modal-x { margin-top: 1.2rem; background: transparent; border: 1px solid var(--line); color: var(--ink-soft); border-radius: 999px; padding: 0.5rem 1.2rem; font-family: var(--mono); font-size: 0.76rem; cursor: pointer; }
.modal-x:hover { color: var(--ink); }

.name-input, .glyph-text {
  width: 100%; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); font-family: var(--body); font-size: 1.1rem;
  padding: 0.7rem 0.9rem; resize: none;
}
.glyph-text { font-family: var(--mono); font-size: 0.72rem; word-break: break-all; }
.name-input:focus, .glyph-text:focus { outline: none; border-color: var(--gold-deep); }
.name-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }
.chip { background: rgba(243, 234, 216, 0.04); border: 1px solid var(--line); color: var(--ink-soft); border-radius: 999px; padding: 0.35rem 0.7rem; font-family: var(--mono); font-size: 0.7rem; cursor: pointer; }
.chip.sel { border-color: var(--gold); color: var(--gold); }
.ios-note { font-family: var(--body); font-style: italic; font-size: 0.82rem; color: var(--ink-faint); margin: 1rem 0 0; line-height: 1.4; }

/* ---- The book ---------------------------------------------------------- */
.book-section { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-deep); margin: 1.2rem 0 0.5rem; }
.book-annals, .book-roll { display: flex; flex-direction: column; gap: 0.5rem; }
.chron { font-family: var(--body); font-size: 0.95rem; line-height: 1.5; color: var(--ink-soft); margin: 0; }
.chron.lit { color: var(--ink); }
.chron.lit .chron-when { color: var(--gold-deep); }
.chron.keeper { color: var(--ink); }
.chron-when { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-faint); margin-right: 0.4rem; letter-spacing: 0.02em; }

/* ---- Hover label ------------------------------------------------------- */
.hover-label {
  position: fixed; transform: translate(-50%, -100%); z-index: 25; pointer-events: none;
  background: rgba(6, 8, 16, 0.82); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.3rem 0.6rem; white-space: nowrap; opacity: 0; transition: opacity 0.2s ease;
  font-size: 0.82rem;
}
.hover-label.shown { opacity: 1; }
.hl-name { font-family: var(--body); font-style: italic; color: var(--gold); }
.hl-latin { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-soft); }
.hl-cond { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-faint); }

/* ---- Toast ------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 9vh; transform: translateX(-50%) translateY(10px);
  z-index: 60; background: rgba(6, 8, 16, 0.9); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.5rem 1.2rem; font-family: var(--body); font-style: italic;
  color: var(--ink); opacity: 0; transition: opacity 0.4s ease, transform 0.4s ease; pointer-events: none;
}
.toast.shown { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- The Constellation ------------------------------------------------- */
.constellation {
  position: fixed; inset: 0; z-index: 85;
  background: radial-gradient(90% 90% at 50% 50%, #0a0d1e 0%, #05060d 75%);
  opacity: 0; transition: opacity 0.7s ease;
}
.constellation.in { opacity: 1; }
.const-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.const-head {
  position: absolute; left: 0; right: 0; top: clamp(1.2rem, 5vh, 3rem);
  text-align: center; pointer-events: none;
}
.const-title {
  font-family: var(--display); font-size: clamp(1.6rem, 5vw, 2.6rem);
  letter-spacing: 0.1em; color: var(--ink); margin: 0;
  text-shadow: 0 0 30px rgba(242, 199, 138, 0.25);
}
.const-sub {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em;
  color: var(--ink-faint); margin: 0.4rem 0 0;
}
.const-close {
  position: absolute; left: 50%; bottom: clamp(1.4rem, 5vh, 3rem); transform: translateX(-50%);
  background: rgba(10, 12, 22, 0.7); border: 1px solid var(--line); color: var(--ink-soft);
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.05em;
  padding: 0.6rem 1.4rem; border-radius: 999px; cursor: pointer; min-height: 44px;
}
.const-close:hover { color: var(--ink); border-color: var(--gold-deep); background: rgba(242, 199, 138, 0.06); }
.const-close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Other-tab veil ---------------------------------------------------- */
.other-tab-veil {
  position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.4rem; text-align: center; padding: 2rem;
  background: rgba(4, 5, 12, 0.94); backdrop-filter: blur(6px);
}
.ot-line { font-family: var(--body); font-style: italic; font-size: 1.2rem; color: var(--ink-soft); max-width: 28rem; line-height: 1.6; }
.other-tab-veil .primary { background: var(--gold); color: #1c1206; border: none; border-radius: 999px; padding: 0.7rem 1.6rem; font-family: var(--mono); font-size: 0.82rem; cursor: pointer; }

@media (max-width: 620px) {
  #voice { bottom: 20vh; font-size: 0.82rem; }
  .hud-info { min-width: 0; }
  #hud-date { font-size: 0.72rem; }
  .tool { font-size: 0.68rem; padding: 0.4rem 0.55rem; min-height: 44px; min-width: 44px; }
  .toolbar { gap: 0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.15s !important; }
  .ember { animation: none; }
}
