/* ─── Reset ─────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;

  /* Colour and font vars are set by the active theme stylesheet. */
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-base, 1rem);
  line-height: 1.6;
}

.app {
  width: 100%;
  max-width: 480px;
  padding: 1.5rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ─── App title ──────────────────────────────────────────────────────────── */

.app-title {
  margin-bottom: 1rem;
  /* Font, size, and colour set by theme stylesheet */
}

/* Each mode shows only its own title span */
body.mode-one-ring  .title-blade-runner { display: none; }
body.mode-blade-runner .title-one-ring  { display: none; }

/* ─── Mode toggle ────────────────────────────────────────────────────────── */

.mode-nav {
  display: flex;
  gap: 0.5rem;
}

.mode-btn {
  flex: 1;
  min-height: 44px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  border-radius: var(--radius-btn, 0);
  transition: background 0.15s, color 0.15s;
}

.mode-btn.is-active {
  background: var(--color-btn-active-bg);
  color: var(--color-btn-active-text);
  border-color: var(--color-btn-active-border, var(--color-border));
}

/* ─── Main section layout ────────────────────────────────────────────────── */

.app-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ─── Controls ───────────────────────────────────────────────────────────── */

.controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.control-group label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-label);
}

select {
  width: 100%;
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  border-radius: var(--radius-input, 0);
  cursor: pointer;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1em;
}

/* ─── Roll button ────────────────────────────────────────────────────────── */

.roll-btn {
  width: 100%;
  min-height: 56px;
  cursor: pointer;
  border: 2px solid var(--color-accent);
  background: var(--color-roll-bg);
  color: var(--color-roll-text);
  font-family: var(--font-ui);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  border-radius: var(--radius-btn, 0);
}

/* ─── Result ─────────────────────────────────────────────────────────────── */

.result {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-flourish {
  text-align: center;
  line-height: 1;
}

.result-meta {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-label);
}

.result-label {
  font-family: var(--font-body);
  font-size: var(--font-size-result, 1.1rem);
}

.reset-btn {
  align-self: flex-start;
  margin-top: 0.5rem;
  min-height: 36px;
  padding: 0 0.75rem;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-label);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-btn, 0);
}

/* ─── Tab bar ────────────────────────────────────────────────────────────── */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  /* Sit above page content; Blade Runner scanline overlay (z-index 9999) is
     pointer-events:none so it won't block taps even though it renders on top */
  z-index: 100;
  /* Safe-area inset for notched phones */
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
  flex: 1;
  min-height: 52px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--color-label);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.tab-btn.is-active {
  color: var(--color-accent);
}

/* Ensure content clears the fixed tab bar. The 4rem already in .app handles
   most cases; add safe-area to cover notched phones. */
.app {
  padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0));
}

/* ─── Tab stub panels ─────────────────────────────────────────────────────── */

.tab-stub-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.tab-stub-label {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--color-label);
  font-style: italic;
}

/* ─── Mode-conditional visibility ────────────────────────────────────────── */

/* Flourish is a visual asset, not a form control — CSS suppression is fine. */
body.mode-blade-runner .result-flourish {
  display: none;
}

/* #season-group and #date-group are suppressed via the hidden attribute by
   app.js, not CSS. Form controls that are display:none still hold live state;
   hidden makes them semantically absent. */

/* ─── Checkbox label ─────────────────────────────────────────────────────── */

.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--color-text);
}

.check-label input[type="checkbox"] {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--color-accent);
}

/* ─── Camp result ─────────────────────────────────────────────────────────── */

.camp-result {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.camp-die-result {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-label);
}

.camp-result[data-outcome-type="evil"] .camp-die-result {
  color: var(--color-accent);
}

.camp-event-label {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--color-text);
}

.camp-event-variant {
  font-family: var(--font-body);
  font-size: var(--font-size-result, 1.1rem);
  line-height: 1.65;
}

/* ─── Event targets ──────────────────────────────────────────────────────── */

.event-targets {
  display: flex;
  gap: 0.5rem;
}

.event-target-btn {
  flex: 1;
  min-height: 56px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  font-family: var(--font-ui);
  font-size: 1rem;
  border-radius: var(--radius-btn, 0);
  transition: background 0.15s, color 0.15s;
}

.event-target-btn.is-active,
.secondary-btn.is-active {
  background: var(--color-btn-active-bg);
  color: var(--color-btn-active-text);
  border-color: var(--color-btn-active-bg);
}

.event-target-any {
  border-left: 2px solid var(--color-border);
  margin-left: 0.25rem;
}

/* ─── Journey result ──────────────────────────────────────────────────────── */

.journey-result {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.journey-meta {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-label);
}

.journey-event-label {
  font-family: var(--font-body);
  font-size: var(--font-size-result, 1.1rem);
  line-height: 1.65;
}

.journey-fatigue {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-label);
}

.journey-on-eye {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-accent);
  border-left: 2px solid var(--color-accent);
  padding-left: 0.75rem;
  line-height: 1.5;
}

/* ─── GM notes collapsible ──────────────────────────────────────────────── */

.journey-notes summary {
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-label);
  list-style: none;
  padding: 0.25rem 0;
  user-select: none;
}

.journey-notes summary::-webkit-details-marker { display: none; }

.journey-notes p {
  margin-top: 0.375rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-label);
  line-height: 1.55;
}

/* ─── Predator section ──────────────────────────────────────────────────── */

.predator-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.secondary-btn {
  min-height: 36px;
  padding: 0 0.875rem;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-label);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-btn, 0);
  transition: color 0.15s, border-color 0.15s;
}

.predator-result {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  border-radius: var(--radius-input, 0);
}

.predator-name {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--color-text);
}

.predator-desc {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.5;
}

.predator-ref {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--color-label);
}

/* ─── Journey actions ──────────────────────────────────────────────────── */

.journey-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.journey-retarget {
  display: flex;
  gap: 0.5rem;
}

.journey-retarget .secondary-btn {
  flex: 1;
}

/* ─── Quick lookups section ─────────────────────────────────────────────── */

.lookups-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.lookups-btns {
  display: flex;
  gap: 0.5rem;
}

.lookups-btns .secondary-btn {
  flex: 1;
}

.lookup-type {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-label);
}

.lookup-rations {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-label);
}
