/* ============================================================
   Garulangit theme tokens + dark mode + theme toggle
   Light mode values below reproduce the original Massively-based
   design exactly; dark mode redefines the same tokens.
   ============================================================ */

:root {
  /* page chrome (behind the content sheet) */
  --gl-page: #242622;
  --gl-page-rgb: 36, 38, 34;

  /* content surfaces */
  --gl-sheet: #F3F0E8;          /* #main, mobile nav panel */
  --gl-footer-bg: #EAE5DA;      /* #footer */

  /* text */
  --gl-ink: #242622;            /* primary text on light surfaces */
  --gl-ink-rgb: 36, 38, 34;
  --gl-muted: #77756E;          /* secondary text, placeholders */
  --gl-muted-rgb: 119, 117, 110;

  /* lines & dividers */
  --gl-line: #D8D2C7;
  --gl-line-rgb: 216, 210, 199;

  /* accent */
  --gl-accent: #B66B50;
  --gl-accent-rgb: 182, 107, 80;

  /* text on the dark chrome (intro / header / nav / copyright) */
  --gl-chrome-ink: #F3F0E8;
  --gl-cream-rgb: 243, 240, 232;

  /* buttons */
  --gl-btn-bg: #242622;         /* primary button on light surfaces */
  --gl-btn-fg: #F3F0E8;
  --gl-chrome-btn-bg: #F3F0E8;  /* primary button on dark chrome */
  --gl-chrome-btn-fg: #242622;

  /* nav */
  --gl-nav-active: #F3F0E8;     /* active nav pill */
  --gl-navwash: rgba(255, 255, 255, 0.175);

  color-scheme: light;
}

html[data-theme="dark"] {
  --gl-page: #171918;
  --gl-page-rgb: 23, 25, 24;

  --gl-sheet: #262824;
  --gl-footer-bg: #20221E;

  --gl-ink: #ECE7D8;
  --gl-ink-rgb: 236, 231, 216;
  --gl-muted: #A29E94;
  --gl-muted-rgb: 162, 158, 148;

  --gl-line: #3B3E37;
  --gl-line-rgb: 59, 62, 55;

  --gl-accent: #D1926F;
  --gl-accent-rgb: 209, 146, 111;

  --gl-chrome-ink: #EDE8DA;
  --gl-cream-rgb: 237, 232, 218;

  --gl-btn-bg: #E6E1D2;
  --gl-btn-fg: #23251F;
  --gl-chrome-btn-bg: #EDE8DA;
  --gl-chrome-btn-fg: #1F211D;

  --gl-nav-active: #31342C;
  --gl-navwash: rgba(255, 255, 255, 0.05);

  color-scheme: dark;
}

/* ---------- smooth theme transition (only while switching) ---------- */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
  transition: background-color 0.35s ease,
              border-color 0.35s ease,
              color 0.35s ease,
              box-shadow 0.35s ease,
              fill 0.35s ease,
              stroke 0.35s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-anim,
  html.theme-anim *,
  html.theme-anim *::before,
  html.theme-anim *::after {
    transition: none !important;
  }
}

/* ---------- theme toggle (pill) ---------- */
.theme-switch {
  display: flex;
  align-items: center;
  align-self: center;
  flex-shrink: 0;
  margin-left: 1.25rem;
}

.theme-toggle {
  position: relative;
  width: 62px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid var(--gl-line);
  background: var(--gl-sheet);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus {
  outline: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--gl-accent);
  outline-offset: 3px;
}

.theme-toggle-icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  color: var(--gl-muted);
  pointer-events: none;
}

.theme-toggle-icons svg {
  width: 13px;
  height: 13px;
  display: block;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gl-accent);
  transition: transform 0.3s cubic-bezier(0.45, 0, 0.2, 1),
              background-color 0.3s ease;
}

html[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(30px);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle-thumb {
    transition: none;
  }
}

/* toggle inside the mobile nav panel */
#navPanel .theme-switch {
  margin: 1.25rem 0 0 0;
  justify-content: flex-start;
}
