/* Traverser layout layered over the shared UI and the existing workspace. */
:root { color-scheme: light; }
:root[data-style="night"] { color-scheme: dark; }

body.wiki-themed {
  --wiki-paper: #faf8f3;
  --wiki-surface: #fffdf8;
  --wiki-raised: #f2ede4;
  --wiki-ink: #25231f;
  --wiki-muted: #625950;
  --wiki-border: #ded5c8;
  --wiki-accent: #8b3929;
  --wiki-on-accent: #fffdf8;
  --wiki-visited: #38664f;
  --wiki-shadow: 0 8px 24px #4b35200d;
  --wiki-gap: clamp(12px, 1.5vw, 22px);
  --wiki-gutter: clamp(12px, 3vw, 48px);
  --bg: var(--wiki-paper);
  --panel: var(--wiki-surface);
  --text: var(--wiki-ink);
  --muted: var(--wiki-muted);
  --line: var(--wiki-border);
  --gold: var(--wiki-accent);
  --green: var(--wiki-visited);
  background: var(--wiki-paper);
  color: var(--wiki-ink);
  padding-bottom: var(--wiki-player-height, 220px);
}

:root[data-style="night"] .wiki-themed {
  --wiki-paper: #171614;
  --wiki-surface: #201e1b;
  --wiki-raised: #2a2621;
  --wiki-ink: #f1eae0;
  --wiki-muted: #c0b3a6;
  --wiki-border: #4a423a;
  --wiki-accent: #f2bb9e;
  --wiki-on-accent: #2b1812;
  --wiki-visited: #9fd3b5;
  --wiki-shadow: 0 8px 24px #0003;
}

.wiki-themed .wiki-topbar {
  position: static;
  display: block;
  padding: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.wiki-themed .wiki-topbar .topbar-inner,
.wiki-themed .wiki-intro,
.wiki-themed #wiki-workspace {
  width: calc(100% - 2 * var(--wiki-gutter));
  max-width: 1580px;
  margin-inline: auto;
}

.wiki-themed .wiki-topbar .topbar-inner {
  min-height: 60px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px clamp(12px, 3vw, 36px);
  padding: 8px 0;
}

.wiki-themed .wiki-topbar .brand {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: normal;
  text-decoration: none;
}

.wiki-themed .wiki-topbar .mainnav {
  position: static;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px clamp(8px, 2vw, 24px);
  background: transparent;
  box-shadow: none;
  width: auto;
  padding: 0;
  border: 0;
}

.wiki-themed .wiki-topbar .mainnav a {
  color: var(--muted);
  font-size: .875rem;
}

.wiki-themed .wiki-topbar .mainnav [aria-current="page"] {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: .3em;
}

.wiki-themed .topbar-end { margin-inline-start: auto; }

.wiki-themed #wiki-style {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

.wiki-themed .wiki-intro { margin-block: clamp(20px, 4vw, 50px) var(--wiki-gap); }

.wiki-themed .wiki-intro-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 18px;
}

.wiki-themed #wiki-page-title,
.wiki-themed #wiki-title,
.wiki-themed .map-heading h2,
.wiki-themed .wiki-study-heading h2 {
  font-family: Georgia, serif;
  font-weight: 400;
  letter-spacing: -.035em;
}

.wiki-themed #wiki-page-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.75rem);
  line-height: 1.08;
}

.wiki-themed #wiki-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, max-content) auto;
  padding: 0;
  gap: 10px;
}

.wiki-themed #wiki-query,
.wiki-themed #wiki-language,
.wiki-themed #wiki-search > button { min-height: 46px; max-width: 100%; }

.wiki-themed #wiki-status {
  margin: 8px 0 14px;
  min-height: 0;
  padding: 0;
  color: var(--muted);
  font-size: .875rem;
}

.wiki-themed #wiki-results {
  margin: 0 0 14px;
  background: var(--panel);
}

.wiki-themed .wiki-workspace-actions { margin: 0; }

body.wiki-themed #wiki-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: var(--wiki-gap);
  height: auto;
  min-height: 0;
  align-items: start;
  margin-block: 0 var(--wiki-gap);
}

body.wiki-themed.wiki-three-column #wiki-workspace {
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.75fr) minmax(0, 1.05fr);
  align-items: stretch;
  height: max(460px, calc(100dvh - var(--wiki-player-height, 220px) - 250px));
}

body.wiki-themed #wiki-workspace > :is(.reading, aside) {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(14px, 2vw, 28px);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--wiki-shadow);
  min-width: 0;
  min-height: 0;
}

body.wiki-themed #wiki-workspace > .reading { padding-inline: clamp(16px, 3vw, 46px); }

.wiki-themed #wiki-title {
  font-size: clamp(1.9rem, 3.5vw, 3.2rem);
  line-height: 1.12;
  margin: .55em 0 .25em;
  overflow-wrap: anywhere;
}

.wiki-themed .reading #wiki-article {
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.75;
  max-height: none;
  overflow: visible;
  padding: 0;
}

body.wiki-themed.wiki-three-column #wiki-article {
  overflow: auto;
  scrollbar-width: thin;
}

.wiki-themed #wiki-article a.wiki-link-visited { color: var(--green); }

.wiki-themed :is(.map-heading h2, .wiki-study-heading h2) {
  font-size: clamp(1.2rem, 2vw, 1.65rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.wiki-themed #wiki-map,
body.wiki-themed.wiki-three-column #wiki-map {
  height: clamp(200px, 34vh, 360px);
  max-height: none;
  background: #090e15;
}

.wiki-themed .legend { flex-wrap: wrap; gap: 4px 12px; }
.wiki-themed .legend span:nth-child(3) { color: var(--muted); }

.wiki-themed :is(button, input:not([type="checkbox"]), textarea, select),
.wiki-themed :is(#wiki-study-panel, #wiki-catalog-panel, #wiki-queue-panel, #wiki-player) :is(button, input:not([type="checkbox"]), textarea, select),
.wiki-themed .wiki-workspace-actions button {
  border-color: var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
}

.wiki-themed #wiki-dictionary-content button.wiki-definition-word {
  border-radius: 3px;
  background: none;
  color: inherit;
}

.wiki-themed #wiki-dictionary-content button.wiki-definition-word:is(:hover, :focus-visible) {
  color: var(--gold);
}

.wiki-themed button:not(:disabled):hover { border-color: var(--gold); }

.wiki-themed :is(a, button, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.wiki-themed #wiki-search > button,
.wiki-themed #wiki-listen,
.wiki-themed .wiki-study-tabs [aria-selected="true"],
.wiki-themed #wiki-pages [aria-current="page"] {
  border-color: var(--gold);
  background: var(--gold) !important;
  color: var(--wiki-on-accent) !important;
}

.wiki-themed :is(#wiki-study-panel .muted, #wiki-dictionary-content a, .wiki-chat-message strong) { color: var(--muted); }
.wiki-themed :is(.wiki-study-tabs, #wiki-catalog-panel, #wiki-queue-list li) { border-color: var(--line); }
.wiki-themed :is(.wiki-chat-message, .wiki-chat-message[data-role="user"]) { background: var(--wiki-raised); }
.wiki-themed .wiki-chat-message[data-role="user"] { border-inline-start: 2px solid var(--gold); }
.wiki-themed :is(#wiki-queue-panel, #wiki-notes) { border-color: var(--line); background: var(--panel); color: var(--text); }
.wiki-themed #wiki-player { background: var(--panel); box-shadow: 0 -5px 24px #0002; }
.wiki-themed #wiki-player #wiki-queue-toggle[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); }
.wiki-themed #wiki-article .wiki-word-active { color: var(--wiki-on-accent) !important; text-decoration-color: currentColor; }

@media (max-width: 820px) {
  body.wiki-themed #wiki-workspace,
  body.wiki-themed.wiki-three-column #wiki-workspace {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }

  body.wiki-themed #wiki-workspace > :is(.reading, aside) {
    order: initial;
    width: 100%;
    max-height: none;
  }

  .wiki-themed .reading #wiki-article,
  body.wiki-themed.wiki-three-column #wiki-article {
    max-height: 65dvh;
    overflow: auto;
  }
}

@media (max-width: 520px) {
  .wiki-themed #wiki-search { grid-template-columns: minmax(0, 1fr) auto; }
  .wiki-themed #wiki-query { grid-area: 1 / 1 / 2 / -1; }
  .wiki-themed #wiki-language { grid-area: 2 / 1; }
  .wiki-themed #wiki-search > button { grid-area: 2 / 2; }

  .wiki-themed #wiki-player .wiki-player-controls {
    scrollbar-width: thin;
    padding: 3px 3px 6px;
  }

  .wiki-themed #wiki-player .wiki-player-controls::-webkit-scrollbar { display: block; }
}

@media (max-width: 360px) {
  .wiki-themed .wiki-topbar .mainnav {
    order: 1;
    flex-basis: 100%;
  }
}

/* ---------- phones and tablets (900px and under): the menu stays one tidy row ----------
   At this width the shared top bar (rekhyt-ui.css) turns its menu into a drop-down:
   a column of big links in a 60px bar. This page keeps its menu on show instead, but
   it still got the column, the big link padding and the fixed height, so the links
   piled up over the title and the search box. */
@media (max-width: 900px) {
  .wiki-themed .wiki-topbar .topbar-inner { height: auto; }
  .wiki-themed .wiki-topbar .mainnav { flex-direction: row; }
  .wiki-themed .wiki-topbar .mainnav a { padding: 4px 0; border-bottom: 0; }
}

/* ---------- phones on their side: the audio player takes less of the screen ----------
   At 300 to 430px tall the player (two rows of buttons, the audio bar and two notes)
   covered half to two thirds of the page. One sliding row of buttons, as on small
   phones, smaller gaps, and each note on one line. */
@media (orientation: landscape) and (max-height: 500px) {
  .wiki-themed #wiki-player { padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .wiki-themed #wiki-player .wiki-player-top { margin-bottom: 4px; }
  .wiki-themed #wiki-player .wiki-player-controls { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
  .wiki-themed #wiki-player .wiki-player-controls > * { flex-shrink: 0; }
  .wiki-themed #wiki-player #wiki-audio { height: 30px; margin-top: 4px; }
  .wiki-themed #wiki-player :is(#wiki-plexus-status, #wiki-audio-cache-status) { display: inline-block; max-width: calc(50% - 10px); margin: 2px 16px 0 0; vertical-align: top; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
