/*
 * DQX Wayfinder — styles.
 *
 * Aesthetic: the classic Dragon Quest "command window" rendered as an
 * illuminated night-sky atlas — deep navy, gold leaf, crisp rounded
 * white-bordered panels, a faint starfield, and engraved display type.
 * Fonts: Cinzel (display/headings) + Zen Kaku Gothic New (bilingual body,
 * renders Latin and Japanese alike). No frameworks.
 */

:root {
  --dq-navy: #0a1733;
  --dq-navy-2: #122352;
  --dq-window: #0d1c44;
  --dq-window-edge: #f4f6ff;
  --dq-border: rgba(244, 246, 255, 0.92);
  --dq-gold: #ffd255;
  --dq-gold-soft: #ffe9a8;
  --dq-cyan: #67e8ff;
  --dq-text: #eef2ff;
  --dq-muted: #9fb0dd;
  --dq-good: #7dffa6;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font-display: "Cinzel", "Zen Kaku Gothic New", Georgia, serif;
  --font: "Zen Kaku Gothic New", system-ui, -apple-system,
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--dq-text);
  background:
    /* faint starfield — two offset dot layers */
    radial-gradient(1.4px 1.4px at 18% 28%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1.2px 1.2px at 72% 16%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1.6px 1.6px at 44% 62%, rgba(206, 226, 255, 0.55), transparent 60%),
    radial-gradient(1.1px 1.1px at 88% 74%, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(1.3px 1.3px at 28% 88%, rgba(255, 255, 255, 0.4), transparent 60%),
    /* aurora glow at the top */
    radial-gradient(1200px 700px at 50% -10%, var(--dq-navy-2), transparent 60%),
    radial-gradient(900px 500px at 85% 0%, rgba(103, 232, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--dq-navy), #060c1d 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  min-height: 100vh;
  line-height: 1.5;
}

::selection { background: rgba(255, 210, 85, 0.3); color: #fff; }

/* subtle scanline flavor + a vignette to frame the page — purely decorative */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
}
.scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 30%, transparent 55%, rgba(2, 6, 18, 0.55) 100%);
}

/* ---------- header ---------- */
.site-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.8rem 1rem 1.4rem;
}
.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  letter-spacing: 0.1em;
  font-weight: 800;
  background: linear-gradient(180deg, #fffefb 0%, var(--dq-gold-soft) 45%, var(--dq-gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 22px rgba(255, 210, 85, 0.25));
}
/* engraved diamond rule beneath the title (a nod to the DQ message cursor) */
.site-header h1::after {
  content: "◆ ◆ ◆";
  display: block;
  margin: 0.55rem auto 0;
  font-size: 0.5em;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--dq-gold);
  -webkit-text-fill-color: var(--dq-gold);
  filter: none;
  opacity: 0.65;
}
.tagline {
  margin: 0.5rem 0 0;
  color: var(--dq-muted);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.tagline em { color: var(--dq-gold); font-style: normal; font-weight: 700; }

/* ---------- layout ---------- */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- DQ "command window" panels ---------- */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--dq-window), #081636);
  border: 3px solid var(--dq-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(10, 23, 51, 0.9);
  padding: 1.25rem 1.25rem 1.4rem;
}
.panel-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--dq-gold);
  border-bottom: 2px solid rgba(255, 210, 85, 0.22);
  padding-bottom: 0.5rem;
}

/* ---------- route fields ---------- */
.field-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.6rem;
  align-items: end;
}
@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .swap-btn { justify-self: center; }
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label {
  font-size: 0.85rem;
  color: var(--dq-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.combo { position: relative; }
.combo-input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  color: var(--dq-text);
  background: rgba(3, 9, 24, 0.7);
  border: 2px solid rgba(244, 246, 255, 0.35);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.combo-input:focus {
  border-color: var(--dq-cyan);
  box-shadow: 0 0 0 3px rgba(103, 232, 255, 0.18);
}
.combo-input::placeholder { color: #6f80ad; }

.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  background: #0b1838;
  border: 2px solid var(--dq-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: none;
}
.combo-list.open { display: block; }
.combo-option {
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.combo-option:hover,
.combo-option.active { background: var(--dq-navy-2); }
.combo-option .opt-en { font-weight: 600; }
.combo-option .opt-jp { font-size: 0.82rem; color: var(--dq-muted); }
.combo-option .opt-meta { font-size: 0.72rem; color: #7286b6; }
.combo-empty { padding: 0.6rem; color: var(--dq-muted); text-align: center; }

.swap-btn {
  height: 44px;
  width: 44px;
  font-size: 1.2rem;
  color: var(--dq-navy);
  background: var(--dq-gold);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s;
}
.swap-btn:hover { transform: rotate(180deg); }

.go-btn {
  margin-top: 1.1rem;
  width: 100%;
  padding: 0.9rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #2a1c00;
  background: linear-gradient(180deg, #fff2c0, var(--dq-gold));
  border: 2px solid #fff;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b8860b, var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.go-btn:hover { filter: brightness(1.06); }
.go-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b8860b; }
.go-btn:focus-visible { outline: 3px solid var(--dq-cyan); outline-offset: 2px; }

/* ---------- results ---------- */
.results { margin-top: 1.25rem; }
.route-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  padding: 0.7rem 0.9rem;
  background: rgba(103, 232, 255, 0.08);
  border: 1px solid rgba(103, 232, 255, 0.3);
  border-radius: 10px;
  font-size: 0.95rem;
}
.route-summary strong { color: var(--dq-cyan); }

.route-steps { list-style: none; margin: 0; padding: 0; }
.route-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  position: relative;
}
.route-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 38px;
  bottom: -4px;
  width: 2px;
  background: rgba(244, 246, 255, 0.2);
}
.step-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: var(--dq-navy-2);
  border: 2px solid var(--dq-border);
  border-radius: 50%;
  z-index: 1;
}
/* gild the journey's endpoints */
.route-step:first-child .step-icon,
.route-step:last-child .step-icon {
  border-color: var(--dq-gold);
  box-shadow: 0 0 0 3px rgba(255, 210, 85, 0.18), 0 0 14px rgba(255, 210, 85, 0.25);
}
.step-body { display: flex; flex-direction: column; gap: 0.05rem; padding-top: 0.1rem; }
.step-body .step-how {
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dq-muted);
}
.step-body .step-how .verb { color: var(--dq-good); }
.step-body .step-how em { font-style: italic; text-transform: none; letter-spacing: 0; }
.step-body .step-place { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.step-body .step-place .jp { font-weight: 400; color: var(--dq-muted); font-size: 0.85rem; }

.results-empty, .results-error {
  padding: 1rem;
  text-align: center;
  color: var(--dq-muted);
  border: 1px dashed rgba(244, 246, 255, 0.2);
  border-radius: 10px;
}
.results-error { color: #ffb4b4; border-color: rgba(255, 120, 120, 0.4); }

/* ---------- config panel: disclosure cards ----------
   Each section is a card: a header bar on top, the content nested in a padded
   body beneath, so the body reads clearly as a child of its heading. */
.config-block {
  margin-bottom: 1rem;
  border: 1px solid rgba(244, 246, 255, 0.09);
  border-radius: 10px;
  background: rgba(6, 12, 30, 0.5);
  overflow: hidden;
}
/* card header bar — shared by the collapsible <summary> and the static <h3> */
.config-h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--dq-gold);
  background: linear-gradient(180deg, rgba(255, 210, 85, 0.14), rgba(255, 210, 85, 0.045));
  border-left: 4px solid var(--dq-gold);
  padding: 0.6rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-name { flex: 1 1 auto; min-width: 0; }
.section-badge {
  flex: none;
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #2a1c00;
  background: var(--dq-gold);
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.section-badge:empty { display: none; }
/* nested body */
.config-body { padding: 0.8rem 0.85rem 0.9rem; }

/* collapsible affordances */
summary.config-h3 { cursor: pointer; list-style: none; user-select: none; }
summary.config-h3::-webkit-details-marker { display: none; }
summary.config-h3::after {
  content: "▾";
  flex: none;
  color: var(--dq-gold);
  font-size: 0.9rem;
  transition: transform 0.15s;
}
details:not([open]) > summary.config-h3::after { transform: rotate(-90deg); }
details[open] > summary.config-h3 { border-bottom: 1px solid rgba(244, 246, 255, 0.08); }
summary.config-h3:hover {
  background: linear-gradient(180deg, rgba(255, 210, 85, 0.24), rgba(255, 210, 85, 0.09));
}
.hint { margin: 0 0 0.6rem; font-size: 0.8rem; color: var(--dq-muted); }
.hint em { color: var(--dq-gold-soft); font-style: italic; }

/* ---------- travel abilities ---------- */
.checks { display: flex; flex-direction: column; gap: 0.1rem; }
.ability-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  transition: background 0.12s;
}
.ability-row:hover { background: rgba(255, 255, 255, 0.04); }
.ability-row.is-locked { opacity: 0.6; }
.check {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.check input { flex: none; width: 18px; height: 18px; accent-color: var(--dq-gold); cursor: pointer; }
.check input:disabled { cursor: not-allowed; }
.check-text { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.check-en { font-size: 0.9rem; line-height: 1.25; }
.check-jp { font-size: 0.75rem; color: var(--dq-muted); }
.emblem-swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.18);
}

.version-tag {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.08rem 0.4rem;
  border-radius: 5px;
  cursor: help;
  background: rgba(103, 232, 255, 0.15);
  color: var(--dq-cyan);
  border: 1px solid rgba(103, 232, 255, 0.32);
}
.version-tag.locked {
  background: rgba(244, 246, 255, 0.06);
  color: var(--dq-muted);
  border-color: rgba(244, 246, 255, 0.2);
}

.info-btn {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(244, 246, 255, 0.3);
  background: transparent;
  color: var(--dq-muted);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.info-btn:hover,
.info-btn[aria-expanded="true"] {
  color: var(--dq-cyan);
  border-color: var(--dq-cyan);
  background: rgba(103, 232, 255, 0.1);
}

.ability-info {
  margin: 0.1rem 0 0.5rem 2rem;
  padding: 0.55rem 0.7rem;
  background: rgba(3, 9, 24, 0.5);
  border: 1px solid rgba(244, 246, 255, 0.1);
  border-left: 3px solid var(--dq-cyan);
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--dq-muted);
}
.ability-info[hidden] { display: none; }
.ability-info p { margin: 0 0 0.5rem; }
.guide-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.guide-links a { color: var(--dq-cyan); text-decoration: none; font-weight: 600; white-space: nowrap; }
.guide-links a:hover { text-decoration: underline; }

/* ---------- story-progress track (sequential versions) ---------- */
.vtrack { display: flex; flex-direction: column; }
.vstep {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 0.65rem;
  align-items: start;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.4rem 0.5rem;
  border-radius: 8px;
  transition: background 0.12s;
}
.vstep:hover { background: rgba(255, 255, 255, 0.04); }
.vstep:focus-visible { outline: 2px solid var(--dq-cyan); outline-offset: 1px; }
/* the connecting rail (each step draws the segment down to the next) */
.vstep:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 26px;
  bottom: -8px;
  width: 2px;
  background: rgba(244, 246, 255, 0.18);
  transition: background 0.15s;
}
.vstep.is-done::before { background: var(--dq-gold); }
/* the dot */
.vdot {
  justify-self: center;
  align-self: start;
  margin-top: 3px;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid var(--dq-muted);
  background: #0b1838;
  z-index: 1;
  transition: all 0.15s;
}
.vstep.is-done .vdot { border-color: var(--dq-gold); background: var(--dq-gold); }
/* current = "you are here": a ring with a gold core (in-progress, not filled) */
.vstep.is-current .vdot {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-color: var(--dq-gold);
  background: radial-gradient(circle, var(--dq-gold) 0 30%, var(--dq-window) 38% 100%);
  box-shadow: 0 0 0 4px rgba(255, 210, 85, 0.18), 0 0 12px rgba(255, 210, 85, 0.5);
  animation: dot-pulse 2.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 210, 85, 0.16), 0 0 10px rgba(255, 210, 85, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255, 210, 85, 0.10), 0 0 16px rgba(255, 210, 85, 0.6); }
}
.vstep.is-future .vdot { opacity: 0.6; }
/* labels */
.vstep-label { display: flex; flex-direction: column; gap: 0.08rem; min-width: 0; }
.vstep-en { font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
.vstep-jp { font-size: 0.76rem; color: var(--dq-muted); }
.vstep.is-current .vstep-en { color: var(--dq-gold); }
.vstep.is-future .vstep-en { color: var(--dq-muted); }
.vstep.is-future .vstep-jp { opacity: 0.7; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0 0; padding: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.3rem 0.3rem 0.6rem;
  background: var(--dq-navy-2);
  border: 1px solid rgba(244, 246, 255, 0.25);
  border-radius: 999px;
  font-size: 0.85rem;
}
.chip button {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: var(--dq-text);
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
.chip button:hover { background: #d65a5a; }
.chips:empty::after { content: "None yet."; color: var(--dq-muted); font-size: 0.82rem; }

.reset-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem;
  font-size: 0.85rem;
  color: var(--dq-muted);
  background: transparent;
  border: 1px solid rgba(244, 246, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
}
.reset-btn:hover { color: #ffb4b4; border-color: rgba(255, 120, 120, 0.4); }

/* ---------- footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  color: #6f80ad;
  font-size: 0.8rem;
}
.site-footer strong { color: var(--dq-muted); }

/* ---------- motion: orchestrated load-in ---------- */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.site-header { animation: rise-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.layout > .panel { animation: rise-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.panel-route { animation-delay: 0.1s; }
.panel-config { animation-delay: 0.2s; }
/* route steps cascade in when results render */
.route-step { animation: rise-in 0.35s ease-out both; }
.route-step:nth-child(2) { animation-delay: 0.04s; }
.route-step:nth-child(3) { animation-delay: 0.08s; }
.route-step:nth-child(4) { animation-delay: 0.12s; }
.route-step:nth-child(5) { animation-delay: 0.16s; }
.route-step:nth-child(n+6) { animation-delay: 0.2s; }

/* ---------- focus + scrollbar polish ---------- */
.combo-input:focus-visible { outline: none; }
.combo-list::-webkit-scrollbar { width: 10px; }
.combo-list::-webkit-scrollbar-thumb {
  background: rgba(255, 210, 85, 0.35);
  border-radius: 999px;
  border: 2px solid #0b1838;
}
.combo-list::-webkit-scrollbar-track { background: transparent; }
.combo-list { scrollbar-width: thin; scrollbar-color: rgba(255, 210, 85, 0.35) transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
  .swap-btn:hover { transform: none; }
}
