/* ══════════════════════════════════════
   Common styles — shared across all pages
   ══════════════════════════════════════ */

/* ── Variables ── */
:root {
  --bg: #0f1118;
  --bg-card: #181b25;
  --bg-card-hover: #1e2230;
  --border: #2a2e3d;
  --border-accent: #3d4260;
  --text: #d8dce8;
  --text-muted: #8890a6;
  --text-dim: #5c6380;
  --accent-ice: #6eb8d7;
  --accent-fire: #d47b5e;
  --accent-green: #7abf8e;
  --accent-gold: #c4a96a;
  --accent-purple: #9b8ec4;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Source Sans 3', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 10px;
}

/* ── Reset ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Hero header ── */
.hero {
  text-align: center;
  padding: 3.5rem 1.5rem 2.5rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(110,184,215,0.08), transparent),
    radial-gradient(ellipse 50% 50% at 70% 60%, rgba(212,123,94,0.06), transparent);
  pointer-events: none;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 0.02em;
  color: #fff;
  position: relative;
}
.hero h1 span {
  display: block;
  font-size: 0.42em;
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.hero .rune-line {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.6em;
}

/* ── Back to home button ── */
.back-link {
  position: absolute;
  top: 1.2rem;
  left: 1.2rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.back-link:hover {
  color: var(--text);
  border-color: var(--border);
  background: rgba(110,184,215,0.06);
}
.back-link svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.footer-brand {
  color: var(--text-dim);
}
.footer-links {
  margin-top: 0.4rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  color: var(--text-dim);
}
.footer a,
.footer a:link,
.footer a:visited {
  color: #7f879c;
  text-decoration: none;
  transition: color 0.2s;
}
.footer a:hover,
.footer a:focus {
  color: #a6c3d1;
}
.release-version {
  color: var(--text-dim);
}

/* ══════════════════════════════════════
   Site header (persistent, sticky)
   ══════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1.1rem;
  height: 52px;
  background: rgba(15, 17, 24, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.sh-logo {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.sh-logo span { color: var(--text-dim); font-weight: 400; }
.sh-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}
.sh-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.sh-link:hover { color: var(--text); background: var(--bg-card-hover); }
.sh-link.active { color: #fff; background: var(--bg-card-hover); }
.sh-caret { font-size: 0.6rem; color: var(--text-dim); }
.sh-dropdown { position: relative; }
.sh-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 10px;
  padding: 0.35rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 310;
}
.sh-menu.open { display: block; }
.sh-menu a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s;
}
.sh-menu a:hover { color: var(--text); background: var(--bg-card-hover); }
.sh-menu a.active { color: #fff; background: var(--bg-card-hover); }
.sh-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-left: auto;
}
.sh-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0 9px;
  flex-shrink: 0;
}
.sh-burger span {
  display: block;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.sh-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sh-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.sh-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 880px) {
  .sh-burger { display: flex; }
  .sh-nav {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-accent);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
    padding: 0.5rem 0.8rem 0.9rem;
    max-height: calc(100vh - 52px);
    overflow-y: auto;
  }
  .sh-nav.open { display: flex; }
  .sh-link { padding: 0.55rem 0.6rem; font-size: 0.92rem; }
  .sh-dropdown { position: static; }
  .sh-menu {
    position: static;
    box-shadow: none;
    border: none;
    background: none;
    padding: 0 0 0.3rem 0.9rem;
    min-width: 0;
  }
  .sh-menu a { padding: 0.45rem 0.6rem; }
  .sh-user .user-nav-name { display: none; }
}

/* ── Compact hero on tool pages (the header handles navigation) ── */
.page-tool .hero { padding: 1.5rem 1rem 1.1rem; }
.page-tool .hero h1 { font-size: 1.55rem; }
.page-tool .hero h1 span {
  font-size: 0.55em;
  letter-spacing: 0.12em;
  margin-top: 0.15rem;
}
.page-tool .hero .rune-line { display: none; }

/* ══════════════════════════════════════
   Buttons — single source of truth
   ══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent-ice);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-outline {
  background: none;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover { opacity: 1; color: var(--text); border-color: var(--border-accent); background: var(--bg-card-hover); }
.btn-outline.active { color: var(--accent-ice); border-color: var(--accent-ice); background: rgba(110, 184, 215, 0.08); }
.btn-danger { background: none; color: var(--accent-fire); border-color: rgba(212, 123, 94, 0.45); }
.btn-danger:hover { opacity: 1; background: rgba(212, 123, 94, 0.12); }
.btn-ghost { background: none; color: var(--text-dim); border-color: transparent; }
.btn-ghost:hover { opacity: 1; color: var(--text); background: var(--bg-card-hover); }
.btn-sm { font-size: 0.78rem; padding: 0.32rem 0.75rem; border-radius: 7px; }
@media (max-width: 600px) {
  .btn { min-height: 44px; } /* comfortable touch target */
  .btn-sm { min-height: 36px; }
}

/* ══════════════════════════════════════
   Confirm dialog (replaces native confirm())
   ══════════════════════════════════════ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(3px);
  padding: 1rem;
}
.confirm-box {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  padding: 1.3rem 1.4rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.confirm-text { font-size: 0.92rem; color: var(--text); line-height: 1.55; }
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

/* ══════════════════════════════════════
   Dropdown menus & popovers (set menu, filters, trainer settings)
   ══════════════════════════════════════ */
.set-menu-wrap { position: relative; }
.sm-caret { font-size: 0.65rem; opacity: 0.7; }
.set-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 10px;
  padding: 0.35rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.set-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
}
.set-menu-item:hover { background: var(--bg-card-hover); }
.set-menu-item.checked { color: var(--accent-ice); }
.smi-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smi-count, .smi-check { font-family: var(--mono); font-size: 0.75rem; color: var(--text-dim); flex-shrink: 0; }
.set-menu-item.checked .smi-check { color: var(--accent-ice); }
.set-menu-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0.55rem 0.7rem 0.2rem;
}
.set-menu-sep { height: 1px; background: var(--border); margin: 0.3rem 0.4rem; }
.filter-pop {
  padding: 0.7rem 0.8rem;
  min-width: 260px;
  width: max-content;
  max-width: min(480px, calc(100vw - 2rem));
}

/* ══════════════════════════════════════
   Toast notifications
   ══════════════════════════════════════ */
.toast-wrap {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  max-width: min(340px, calc(100vw - 2rem));
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-left: 3px solid var(--accent-green);
  border-radius: 10px;
  padding: 0.65rem 1.1rem;
  color: var(--text);
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.25s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.error { border-left-color: var(--accent-fire); }
.toast.toast-out { opacity: 0; transform: translateX(20px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; transition: none; }
}

/* ══════════════════════════════════════
   Loading skeletons
   ══════════════════════════════════════ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border-radius: 8px;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(140, 150, 180, 0.09) 50%, transparent 70%);
  animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}
.skeleton-row { height: 2.2rem; margin-bottom: 0.5rem; }
.skeleton-block { height: 9rem; }

/* ── Keyboard hint chip ── */
.kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 0.4rem;
  line-height: 1.6;
}

/* ── Small shared utilities (used by JS-generated markup) ── */
.empty-note { font-size: 0.82rem; color: var(--text-dim); }
.th-sub {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}
.td-sub { font-size: 0.72rem; font-weight: 400; color: var(--text-dim); }

/* ── User nav (injected by auth.js) ── */
/* ── Language switcher ── */
.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.lang-switch a {
  padding: 0.2rem 0.55rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}
.lang-switch a.active {
  color: var(--text);
  background: var(--bg-card-hover);
}
.lang-switch a:not(.active):hover {
  color: var(--text-muted);
}
/* Standalone placement on pages without #user-nav (login/register) */
.lang-switch.floating {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  z-index: 200;
}

.user-nav-name {
  color: var(--text-muted);
}
.admin-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(196,169,106,0.15);
  color: var(--accent-gold);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  vertical-align: middle;
}
.user-nav-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.user-nav-logout:hover {
  color: var(--text);
  border-color: var(--border-accent);
  background: rgba(212,123,94,0.08);
}
.user-nav-login {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.2s;
}
.user-nav-login:hover {
  color: var(--text);
  border-color: var(--border-accent);
  background: rgba(110,184,215,0.08);
}

/* ── Responsive base ── */
@media (max-width: 600px) {
  .hero { padding: 3rem 1rem 2rem; }
  .back-link { top: 0.8rem; left: 0.6rem; font-size: 0.75rem; padding: 0.3rem 0.6rem; }
}

/* ── Icelandic character strip (char-strip.js) ── */
.char-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin: 0.7rem auto 0;
  max-width: 620px;
}
.char-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  min-width: 2.1rem;
  padding: 0.35rem 0;
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}
.char-btn:hover { border-color: var(--accent-ice); background: var(--bg-card-hover); }

/* ── Global word search (header button + palette overlay) ── */
.user-nav-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.user-nav-search:hover {
  color: var(--text);
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}
.user-nav-search svg { width: 16px; height: 16px; fill: currentColor; }
.gs-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 1rem 1rem;
}
.gs-box {
  width: min(560px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.gs-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  padding: 0.85rem 1rem;
}
.gs-results { max-height: 50vh; overflow-y: auto; padding: 0.35rem; }
.gs-row {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
}
.gs-row:hover, .gs-row.sel { background: var(--bg-card-hover); }
.gs-word { font-family: var(--mono); font-weight: 600; color: var(--text); }
.gs-trans {
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.gs-cat {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-purple);
  flex-shrink: 0;
}
.gs-hint { padding: 0.8rem 1rem; color: var(--text-dim); font-size: 0.85rem; }

/* Gear button in the site header (next to the nickname) */
.user-nav-profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.user-nav-profile:hover {
  color: var(--text);
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}
.user-nav-profile svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
