/* options.css — the options panel. Owned by lead.
 *
 * Same language as the title card: gold hairlines on black, serif, restraint. It sits
 * above the title, gameplay and ending screens. The panel remains reachable in chapters;
 * opening it disables the dialogue advance layer so a settings tap cannot skip a line.
 */

.opt {
  position: fixed;
  top: 0; right: 0;
  z-index: 600;               /* above #boot (500) and .end (300) */
  font-family: var(--serif, Georgia, serif);
  pointer-events: none;       /* the layer is inert; its children are not */
}
.opt[hidden] { display: none; }
.opt > * { pointer-events: auto; }

/* --- the gear ------------------------------------------------------------- */
.opt-gear {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: rgba(4, 3, 8, .42);
  border: 1px solid rgba(201, 162, 39, .28);
  border-radius: 0;
  cursor: pointer;
  opacity: .5;
  transition: opacity .4s ease, border-color .4s ease, background .4s ease;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
}
.opt-gear:hover,
.opt-gear:focus-visible,
.opt.is-open .opt-gear { opacity: 1; border-color: rgba(201, 162, 39, .7); background: rgba(4, 3, 8, .8); }
.opt-gear svg { width: 20px; height: 20px; color: #c9a227; }
.opt.is-open .opt-gear svg { transform: rotate(35deg); }
.opt-gear svg { transition: transform .5s cubic-bezier(.22, 1, .36, 1); }

/* --- the panel ------------------------------------------------------------ */
.opt-panel {
  position: absolute;
  top: 66px; right: 16px;
  width: min(330px, calc(100vw - 32px));
  padding: 20px 22px 18px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(201, 162, 39, .07), transparent 62%),
    rgba(5, 4, 5, .97);
  border: 1px solid rgba(201, 162, 39, .3);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .8);
  animation: opt-in .32s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes opt-in { from { opacity: 0; transform: translateY(-8px); } }

.opt-h {
  margin: 12px 0 16px;
  font-size: 12px; font-weight: 500; font-style: italic;
  letter-spacing: .38em; text-indent: .38em;
  text-align: center; color: #c9a227;
}

.opt-rule {
  height: 1px; position: relative;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, .5), transparent);
}
.opt-rule i {
  position: absolute; left: 50%; top: 50%;
  width: 4px; height: 4px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: #d9b545; box-shadow: 0 0 8px rgba(217, 181, 69, .8);
}

/* --- rows ----------------------------------------------------------------- */
.opt-row {
  display: grid;
  grid-template-columns: 1fr 118px 38px;
  align-items: center;
  gap: 10px;
  margin: 13px 0;
}
.opt-k {
  font-size: 9.5px; font-weight: 600;
  letter-spacing: .26em;
  color: #9a917e;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.opt-v {
  font-size: 10px; text-align: right; color: #c9a227;
  font-variant-numeric: tabular-nums;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Restyled native range: keeps keyboard + AT behaviour, loses the chrome. */
.opt-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px;
  background: transparent; cursor: pointer;
}
.opt-slider::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(90deg, #c9a227 var(--fill, 50%), rgba(201, 162, 39, .22) var(--fill, 50%));
}
.opt-slider::-moz-range-track {
  height: 1px;
  background: linear-gradient(90deg, #c9a227 var(--fill, 50%), rgba(201, 162, 39, .22) var(--fill, 50%));
}
.opt-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 9px; height: 9px; margin-top: -4px;
  background: #d9b545;
  transform: rotate(45deg);
  box-shadow: 0 0 9px rgba(217, 181, 69, .7);
}
.opt-slider::-moz-range-thumb {
  width: 9px; height: 9px; border: none; border-radius: 0;
  background: #d9b545; box-shadow: 0 0 9px rgba(217, 181, 69, .7);
}
.opt-slider:focus-visible { outline: 1px solid rgba(201, 162, 39, .6); outline-offset: 4px; }

/* --- segmented text speed -------------------------------------------------- */
.opt-row-seg { grid-template-columns: 1fr; gap: 8px; }
.opt-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.opt-seg button {
  padding: 7px 2px;
  font-size: 8.5px; font-weight: 700; letter-spacing: .1em;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #8d8474;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, .2);
  cursor: pointer;
  transition: color .3s ease, border-color .3s ease, background .3s ease;
  -webkit-tap-highlight-color: transparent;
}
.opt-seg button:hover { color: #d8cfbe; border-color: rgba(201, 162, 39, .45); }
.opt-seg button.is-on {
  color: #050405; background: #c9a227; border-color: #c9a227; font-weight: 800;
}

/* --- checkbox -------------------------------------------------------------- */
.opt-row-check { grid-template-columns: 1fr auto; cursor: pointer; }
.opt-check {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin: 0;
  border: 1px solid rgba(201, 162, 39, .45);
  background: transparent; cursor: pointer;
  display: grid; place-items: center;
}
.opt-check:checked::after {
  content: ""; width: 7px; height: 7px;
  background: #d9b545; transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(217, 181, 69, .8);
}
.opt-check:focus-visible { outline: 1px solid rgba(201, 162, 39, .6); outline-offset: 3px; }

/* --- actions --------------------------------------------------------------- */
.opt-actions { display: grid; gap: 7px; margin-top: 16px; }
.opt-btn {
  padding: 11px 10px;
  font-family: var(--serif, Georgia, serif);
  font-size: 10px; letter-spacing: .26em; text-indent: .26em;
  color: #e8d9a6;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, .38);
  cursor: pointer;
  transition: background .35s ease, color .35s ease, border-color .35s ease;
  -webkit-tap-highlight-color: transparent;
}
.opt-btn:hover { background: rgba(201, 162, 39, .12); color: #fff6cf; }
.opt-btn-warn { color: #b98c8c; border-color: rgba(185, 140, 140, .3); }
.opt-btn-warn:hover { background: rgba(200, 16, 46, .14); color: #ffd7d7; border-color: rgba(200, 16, 46, .5); }
.opt-btn-warn.is-armed { background: rgba(200, 16, 46, .2); color: #ffe0e0; border-color: rgba(200, 16, 46, .7); }

.opt-note {
  margin-top: 10px; min-height: 13px;
  font-size: 10px; font-style: italic; text-align: center;
  color: #8d8474; opacity: 0;
}
.opt-note.is-on { animation: opt-note 3.4s ease forwards; }
@keyframes opt-note { 0% { opacity: 0; } 12% { opacity: 1; } 76% { opacity: 1; } 100% { opacity: 0; } }

/* While the panel is open, clicks must not also advance the story behind it. */
body.mi-options-open .mi-advance { pointer-events: none !important; }

/* Global reduce-motion switch driven from the panel (separate from the OS setting). */
body.mi-reduce-motion * {
  animation-duration: .001s !important;
  transition-duration: .001s !important;
}

/* The gear must clear the phone notch and the stats HUD. */
@media (max-width: 640px) {
  .opt-gear { top: max(12px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; }
  .opt-panel { top: calc(max(12px, env(safe-area-inset-top)) + 52px); right: 12px; }
}
