/* ብራና OS — styles.
 *
 * Colours come from Ethiopian manuscripts and telsem scrolls: black ink and red
 * rubric on parchment, with the blue, ochre and green of telsem pigments.
 * Everything is a token so the night theme only has to redefine tokens.
 */
:root {
  --parchment: #ecdcbc;
  --vellum: #dcc497;
  --ink: #1c1510;
  --ink-soft: #4a3b2c;
  --rubric: #a3261b;
  --blue: #2c4a8a;
  --green: #3d6a3a;
  --ochre: #d39b1d;
  --sky: var(--ochre);           /* the medallion's inner ring, tinted by the time of day */
  --line: rgba(28, 21, 16, .28);
  --shadow: rgba(28, 21, 16, .22);
  --bg: var(--parchment);
  --fg: var(--ink);
  --panel: #f3e7cd;
  --disc: var(--parchment);      /* the parchment disc behind the portrait */
  --word: #7a6a1c;               /* words found in the background: a muted olive-gold */
  /* the chessboard: its own tokens, so pieces stay readable in every palette */
  --board-light: #f6ecd6; --board-dark: #c39a66;
  --piece-light: #fffaf0; --piece-light-edge: #1c1510;
  --piece-dark: #1c1510;  --piece-dark-edge: transparent;

  --mono: "JetBrains Mono", "Noto Sans Ethiopic", ui-monospace, monospace;
  --geez: "Abyssinica SIL", "Noto Sans Ethiopic", serif;
  --serif: "Cormorant Garamond", "Abyssinica SIL", Georgia, serif;   /* Ge'ez inside serif text uses the manuscript face */
}
:root[data-theme="night"] {
  --bg: #17110c;
  --fg: #ecdcbc;
  --panel: #221912;
  --line: rgba(236, 220, 188, .22);
  --shadow: rgba(0, 0, 0, .5);
  --ink-soft: #bfa983;
  --rubric: #d4473a;
  --word: #d2b25c;
  --board-light: #3b2d20; --board-dark: #22180f;
  --piece-light: #ecdcbc; --piece-light-edge: #0d0906;
  --piece-dark: #0d0906;  --piece-dark-edge: #bfa983;
}

* { box-sizing: border-box }
html, body { margin: 0; height: 100% }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0 }
a { color: var(--rubric) }
.geez { font-family: var(--geez) }
.red { color: var(--rubric) }

/* Parchment vignette, above the living-manuscript canvas */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(90, 60, 20, .2) 100%);
}
:root[data-theme="night"] body::after { background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(0, 0, 0, .5) 100%) }
#field { position: fixed; inset: 0; z-index: 0; pointer-events: none }

/* The boot screen is in boot.css. Without JavaScript, a short plain page instead: */
.noscript { max-width: 620px; margin: 0 auto; padding: 48px 20px; font-size: 14px; line-height: 1.7 }
.noscript h1 { font-family: var(--serif); font-size: 40px; margin: 0 0 12px }
.noscript h1 .geez { color: var(--rubric) }
@keyframes blink { 50% { opacity: .25 } }

/* ---------- MENU BAR ---------- */
#bar { position: fixed; top: 0; left: 0; right: 0; height: 34px; z-index: 40; display: flex; align-items: stretch; border-bottom: 1px solid var(--fg); background: var(--bg); font-size: 12px }
#bar > * { display: flex; align-items: center; padding: 0 12px; border-right: 1px solid var(--line) }
#bar .logo { font-family: var(--geez); font-size: 18px; color: var(--rubric) }
#bar .spacer { flex: 1; border: 0 }
#bar .right { border-left: 1px solid var(--line); border-right: 0 }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 7px; box-shadow: 0 0 0 3px rgba(61, 106, 58, .2); animation: breathe 3s ease-in-out infinite }
@keyframes breathe { 50% { box-shadow: 0 0 0 6px rgba(61, 106, 58, 0) } }
#clock { min-width: 150px; justify-content: center; white-space: nowrap }

/* ---------- DESKTOP ---------- */
#desk { position: fixed; inset: 34px 0 0 0; z-index: 1; isolation: isolate }
.corner { position: absolute; display: flex; flex-direction: column; gap: 2px; padding: 6px; text-align: left; z-index: 2 }
.corner .n { color: var(--rubric); font-size: 11px }
.corner .f { font-size: 10px; color: var(--ink-soft) }
.corner .t { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1; transition: transform .25s ease, color .25s }
.corner .a { font-family: var(--geez); font-size: 15px; color: var(--rubric) }
.corner:hover .t, .corner:focus-visible .t { color: var(--rubric); transform: translateX(4px) }
.c2:hover .t, .c4:hover .t { transform: translateX(-4px) }
.c1 { top: 24px; left: 28px }
.c2 { top: 24px; right: 28px; text-align: right; align-items: flex-end }
.c3 { bottom: 24px; left: 28px }
.c4 { bottom: 24px; right: 28px; text-align: right; align-items: flex-end }

/* The medallion. Its size is the largest square that fits between the bars. */
.hero {
  --size: min(calc(100vh - 96px), 76vw, 780px);
  position: absolute; left: 50%; top: 50%;
  width: var(--size); height: var(--size);
  translate: -50% -50%;
  perspective: 1400px;
  user-select: none; -webkit-user-select: none;
  isolation: isolate;
}
.tilt { position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform; touch-action: pan-y }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; will-change: transform }
.layer.ring { cursor: grab }
.tilt.spinning .layer.ring, .tilt.spinning { cursor: grabbing }
#portrait { image-rendering: pixelated }
/* Only the ring layer takes the pointer (spin, portrait clicks are worked out from
   the distance to the centre); the layers above it let presses through, except the eyes. */
.layer.star, .layer.eyes, #portrait, .cartouche { pointer-events: none }
.layer.eyes [data-secret], .layer.eyes .eye { pointer-events: auto }

.fidel-ring text { font-family: var(--geez); font-size: 14px; fill: var(--fg); transition: fill .2s; cursor: help }
.fidel-ring text:hover { fill: var(--rubric) }
.fidel-ring .sep { fill: var(--rubric); cursor: default }

/* The eight points: one per secret. Unfound points breathe in turn; found ones burn red. */
.point { fill: var(--ochre); stroke: var(--fg); stroke-width: 1.5; transition: fill .4s; animation: point 8s ease-in-out infinite }
.point.found { fill: var(--rubric); animation: none; filter: drop-shadow(0 0 4px var(--rubric)) }
@keyframes point { 0%, 80%, 100% { opacity: 1 } 88% { opacity: .35 } }

/* Telsem eyes: red-rimmed almonds that follow the reader, and sometimes blink */
.eye { cursor: pointer }
.eye .lid { transform-box: fill-box; transform-origin: center; transition: transform .09s ease-in }
.eye.blink .lid { transform: scaleY(.08) }

/* The name, on a manuscript cartouche across the foot of the medallion */
.cartouche {
  position: absolute; left: 50%; bottom: -1%; translate: -50% 0;
  background: var(--panel); border: 2px solid var(--fg); box-shadow: 6px 6px 0 var(--rubric);
  padding: 4px 26px 6px; text-align: center; white-space: nowrap; z-index: 3;
}
.cartouche::before, .cartouche::after {
  content: "✦"; position: absolute; top: 50%; translate: 0 -50%; color: var(--rubric); font-size: 12px;
}
.cartouche::before { left: 8px }
.cartouche::after { right: 8px }
.cartouche .am { font-family: var(--geez); font-size: calc(var(--size) * .085); line-height: 1; color: var(--rubric); text-shadow: 2px 2px 0 var(--fg) }
.cartouche .en { font-family: var(--serif); font-style: italic; font-size: clamp(15px, calc(var(--size) * .032), 22px) }
.cartouche .role { font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-soft) }

/* An ink star where the desk is clicked */
.blot { position: fixed; width: 28px; height: 28px; margin: -14px 0 0 -14px; pointer-events: none; z-index: 5; animation: blot .9s ease-out forwards }
@keyframes blot { from { transform: scale(.2) rotate(0); opacity: .9 } to { transform: scale(1.6) rotate(45deg); opacity: 0 } }

/* ---------- WINDOWS ---------- */
.win {
  position: absolute; z-index: 10;
  width: min(720px, calc(100vw - 32px)); height: min(520px, calc(100vh - 90px));
  display: flex; flex-direction: column;
  background: var(--panel); border: 2px solid var(--fg); box-shadow: 8px 8px 0 var(--shadow);
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes pop { from { transform: scale(.94) translateY(8px); opacity: 0 } }
.win.focus { box-shadow: 8px 8px 0 var(--rubric) }
.win.closing { animation: shut .16s ease-in forwards }
@keyframes shut { to { transform: scale(.96); opacity: 0 } }
.tbar {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 6px 0 12px;
  border-bottom: 2px solid var(--fg); cursor: grab; user-select: none; touch-action: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, var(--line) 3px 4px);
}
.tbar .ttl { background: var(--panel); padding: 0 8px; font-weight: 600 }
.tbar .ttl .geez { color: var(--rubric); margin-right: 6px }
.tbar .grow { flex: 1 }
.tbar .x { width: 22px; height: 22px; border: 1px solid var(--fg); background: var(--panel); line-height: 1 }
.tbar .x:hover { background: var(--rubric); color: var(--parchment) }
.body { flex: 1; overflow: auto; padding: 18px 20px; line-height: 1.65 }
.body.flush { padding: 0; overflow: hidden }
.body h2 { font-family: var(--serif); font-size: 30px; margin: 0 0 4px; line-height: 1.1 }
.body h3 { font-family: var(--serif); font-size: 21px; margin: 18px 0 4px }
.body p { margin: 0 0 12px; max-width: 62ch }
.rule {
  height: 10px; margin: 16px 0;
  background:
    radial-gradient(circle at 5px 5px, var(--rubric) 2px, transparent 2.5px) 0 0 / 20px 10px,
    linear-gradient(var(--fg), var(--fg)) center / 100% 1px no-repeat;
}
.tag { display: inline-block; border: 1px solid var(--line); padding: 0 6px; margin: 0 4px 4px 0; font-size: 11px }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 14px; font-size: 12px; margin: 10px 0 14px }
.kv dt { color: var(--ink-soft); text-transform: uppercase; letter-spacing: .12em; font-size: 10px; padding-top: 3px }
.kv dd { margin: 0 }
.todo { border-left: 3px solid var(--ochre); padding: 4px 10px; color: var(--ink-soft); font-style: italic; font-size: 12px }

/* Terminal */
.term { background: var(--ink); color: #e9d9b4; font-size: 12.5px; padding: 14px; height: 100%; overflow: auto }
.term .p { color: #e0533f }
.term input { background: none; border: 0; outline: 0; color: inherit; font: inherit; width: 70% }
.term pre { margin: 0; white-space: pre-wrap }
.term a { color: #e0533f }

/* Fidel typewriter */
.tw textarea { width: 100%; min-height: 90px; font: inherit; background: transparent; border: 1px solid var(--line); padding: 10px; color: inherit; resize: vertical }
.tw .out { font-family: var(--geez); font-size: 44px; line-height: 1.25; min-height: 70px; color: var(--rubric); word-break: break-word; margin: 10px 0 }
.tw .out span { display: inline-block; animation: inkin .35s ease }
@keyframes inkin { from { opacity: 0; transform: translateY(-6px) scale(1.2); filter: blur(2px) } }
.chips button { border: 1px solid var(--line); padding: 2px 8px; margin: 0 6px 6px 0; font-size: 12px }
.chips button:hover { border-color: var(--rubric); color: var(--rubric) }

/* Chess squares (About) */
.board { display: grid; grid-template-columns: repeat(4, 28px); border: 2px solid var(--fg); width: max-content; margin: 6px 0 12px }
.board span { width: 28px; height: 28px; display: grid; place-items: center; font-size: 18px }
.board span:nth-child(8n+1), .board span:nth-child(8n+3), .board span:nth-child(8n+6), .board span:nth-child(8n+8) { background: var(--fg); color: var(--bg) }
.board .k { cursor: pointer; color: var(--rubric) !important; transition: transform .2s }
.board .k:hover { transform: translate(3px, -6px) rotate(-8deg) }

/* Toast for discovered secrets */
#toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 60;
  max-width: min(520px, calc(100vw - 32px));
  transform: translate(-50%, calc(100% + 60px)); visibility: hidden;
  background: var(--panel); border: 2px solid var(--fg); box-shadow: 6px 6px 0 var(--rubric); padding: 12px 16px;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), visibility .35s;
}
#toast.on { transform: translate(-50%, 0); visibility: visible }
#toast b { color: var(--rubric); font-family: var(--geez); font-size: 15px }

/* ---------- PHONE ---------- */
@media (max-width: 760px) {
  body { overflow: auto }
  #bar { height: 46px }
  #bar .avail { display: none }
  #bar .logo { width: 46px; justify-content: center; font-size: 21px }
  #clock { min-width: 0; font-size: 11px; padding: 0 10px; flex: 1 1 auto; justify-content: flex-end }
  .clk-y { display: none }                   /* the year is in the date app */
  #desk { position: relative; inset: auto; padding: 60px 16px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px }
  .hero { --size: min(calc(100vw - 32px), 460px); position: relative; left: auto; top: auto; translate: none; margin: 0 auto 10px; grid-column: 1 / -1; order: -1 }
  .corner { position: relative; inset: auto; border: 1px solid var(--line); padding: 12px; align-items: flex-start !important; text-align: left !important; background: var(--panel) }
  .corner .t { font-size: 24px }
  .cartouche { padding: 4px 20px 6px; white-space: normal; width: max-content; max-width: 92% }
  .cartouche .role { letter-spacing: .12em }
  .win { position: fixed; inset: 46px 0 0 0 !important; width: 100%; height: auto; border-width: 2px 0 0; box-shadow: none }
}
@media (max-width: 359px) { .clk-d { display: none } }   /* the smallest phones: just the time */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important }
}
