/* ═══════════════════════════════════════════════════════
   Commodore Caverns — Shared Stylesheet
   Section pages use the wooden wall background.
   Main hub (index.html) and map (map.html) are self-contained.
═══════════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg:          #0c1820;
  --gold:        #f0b030;
  --orange:      #e07820;
  --rust:        #c45010;
  --deep:        #8a2e00;
  --cream:       #f2e0b8;
  --navy:        #1a2a45;
  --wood-mid:    #c07832;
  --wood-line:   #4a2208;
  --parch-light: #f7e8cc;
  --parch-mid:   #eedcb4;
  --parch-dark:  #dfc898;
  --parch-text:  #3a1f08;
  --parch-link:  #7a2e00;
  --nav-h:       52px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Josefin Sans', sans-serif;
  color: var(--parch-text);
  overflow-x: hidden;
}

/* ── Wooden wall background (all section pages) ── */
.section-page {
  background-color: var(--wood-mid);
  background-image:
    repeating-linear-gradient(
      180deg,
      rgba(255, 218, 120, 0.30)  0px,
      rgba(255, 210,  90, 0.10) 12px,
      transparent               16px,
      transparent               66px,
      rgba( 50,  18,   4, 0.45) 66px,
      rgba( 30,  10,   2, 0.82) 70px,
      rgba( 50,  18,   4, 0.15) 73px,
      transparent               80px
    ),
    repeating-linear-gradient(
      91.8deg,
      transparent             0px,
      transparent            95px,
      rgba(90, 40, 10, 0.06) 95px,
      rgba(90, 40, 10, 0.06) 98px,
      transparent            98px,
      transparent           210px
    ),
    repeating-linear-gradient(
      180deg,
      #cc8038  0px,
      #cc8038 40px,
      #b97030 40px,
      #b97030 80px
    );
  min-height: 100dvh;
}

/* ── Sticky nav ── */
.cave-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: linear-gradient(180deg, #3a1604 0%, #281006 100%);
  border-bottom: 2px solid rgba(240, 176, 48, 0.22);
  box-shadow: 0 2px 16px rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.25rem;
}

.nav-logo {
  height: 30px;
  width: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
  flex-shrink: 0;
}

.nav-sep {
  width: 1px;
  height: 18px;
  background: rgba(240, 176, 48, 0.2);
  flex-shrink: 0;
}

.nav-link {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(240, 176, 48, 0.6);
  text-decoration: none;
  transition: color 0.2s;
  flex-shrink: 0;
}
.nav-link:hover { color: var(--gold); }

.nav-breadcrumb {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(242, 224, 184, 0.35);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Page layout ── */
.section-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 5rem;
}

/* ── Section hero ── */
.section-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-icon {
  font-size: 3.2rem;
  display: block;
  margin-bottom: 0.65rem;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.45));
}

.section-hero h1 {
  font-family: 'Alfa Slab One', serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  text-shadow:
    3px 3px 0 var(--wood-line),
    2px 2px 10px rgba(0,0,0,0.45),
    0 0 40px rgba(240,176,48,0.30);
  margin-bottom: 0.5rem;
  line-height: 1.1;
}

.section-tagline {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255, 238, 195, 0.92);
  text-shadow: 0 1px 4px rgba(0,0,0,0.55), 0 2px 10px rgba(0,0,0,0.3);
}

/* ── Content grid ── */
.content-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.75rem;
}

@media (max-width: 680px) {
  .content-grid { grid-template-columns: 1fr; }
}

.card.full-width { grid-column: 1 / -1; }

/* ── Card (parchment notice board) ── */
.card {
  background-image:
    radial-gradient(circle at 11px 11px,            #f5d060 3px, #9a7010 5px, transparent 6px),
    radial-gradient(circle at calc(100% - 11px) 11px, #f5d060 3px, #9a7010 5px, transparent 6px),
    radial-gradient(circle at 11px calc(100% - 11px), #f5d060 3px, #9a7010 5px, transparent 6px),
    radial-gradient(circle at calc(100% - 11px) calc(100% - 11px), #f5d060 3px, #9a7010 5px, transparent 6px),
    linear-gradient(175deg, var(--parch-light), var(--parch-mid) 55%, var(--parch-dark));
  border: 3px solid var(--wood-line);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255,220,140,0.2),
    4px 6px 18px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
  border-color: rgba(160, 80, 20, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255,220,140,0.2),
    4px 6px 24px rgba(0,0,0,0.45),
    0 0 0 1px rgba(240,176,48,0.18);
}

.card-header {
  background: linear-gradient(135deg, #3e1a06, #5c2a0e 55%, #3e1a06);
  border-bottom: 2px solid rgba(0,0,0,0.32);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
}

.card:hover .card-header {
  background: linear-gradient(135deg, #4e2208, #6e3210 55%, #4e2208);
}

.card-icon { font-size: 1.1rem; flex-shrink: 0; }

.card-title {
  font-family: 'Alfa Slab One', serif;
  font-size: clamp(0.78rem, 2vw, 0.92rem);
  color: var(--gold);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.2;
}

.card-body {
  padding: 0.9rem 1.1rem 1.1rem;
  flex: 1;
}

.card-intro {
  font-size: 0.76rem;
  font-style: italic;
  color: rgba(58, 31, 8, 0.62);
  line-height: 1.7;
  margin-bottom: 0.85rem;
}

.card-text {
  font-size: 0.78rem;
  line-height: 1.72;
  color: var(--parch-text);
  margin-bottom: 0.55rem;
}
.card-text:last-child { margin-bottom: 0; }

.card-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-links a {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--parch-link);
  text-decoration: none;
  letter-spacing: 0.02em;
  line-height: 1.4;
  transition: color 0.2s, gap 0.2s;
}

.card-links a::before {
  content: '›';
  font-size: 1.1rem;
  line-height: 1;
  color: var(--rust);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.card-links a:hover { color: #3a1000; gap: 0.6rem; }
.card-links a:hover::before { transform: translateX(2px); }

.badge {
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rust);
  background: rgba(196,80,16,0.12);
  border: 1px solid rgba(196,80,16,0.28);
  border-radius: 2px;
  padding: 0.06em 0.4em;
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
}

.card-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(58,31,8,0.18), transparent);
  margin: 0.5rem 0;
}

/* ── Sub-section divider (used on hierarchical pages like The Saloon) ── */
.subsection-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 3rem 0 1.5rem;
}

.subsection-divider::before,
.subsection-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,176,48,0.28), transparent);
}

.subsection-label {
  font-family: 'Alfa Slab One', serif;
  font-size: clamp(0.82rem, 2.2vw, 1rem);
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
  text-shadow: 1px 1px 0 var(--wood-line);
  opacity: 0.85;
}

/* ── Card expand overlay ── */
.card-ov {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.card-ov--open {
  opacity: 1;
  pointer-events: all;
}

.card-ov__back {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 1, 0.78);
  cursor: pointer;
}

.card-ov__panel {
  position: relative;
  z-index: 1;
  width: min(780px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 4px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.85);
  transform: scale(0.96) translateY(14px);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-ov--open .card-ov__panel {
  transform: scale(1) translateY(0);
}

.card-ov__close {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  z-index: 10;
  background: rgba(20, 10, 3, 0.88);
  border: 1px solid rgba(240, 176, 48, 0.28);
  color: rgba(240, 176, 48, 0.65);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.32rem 0.7rem;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.card-ov__close:hover {
  color: var(--gold);
  border-color: rgba(240, 176, 48, 0.55);
}

/* Expanded card fills the panel — larger text, more breathing room */
.card-ov__content .card {
  cursor: default;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.card-ov__content .card:hover {
  border-color: var(--wood-line);
  box-shadow: none;
}

.card-ov__content .card-header {
  padding: 0.9rem 1.4rem;
}

.card-ov__content .card-icon { font-size: 1.4rem; }

.card-ov__content .card-title {
  font-size: clamp(0.92rem, 2.5vw, 1.1rem);
}

.card-ov__content .card-body {
  padding: 1.4rem 1.8rem 2rem;
}

.card-ov__content .card-intro {
  font-size: 0.86rem;
  margin-bottom: 1.1rem;
}

.card-ov__content .card-text {
  font-size: 0.88rem;
  line-height: 1.8;
  margin-bottom: 0.75rem;
}

.card-ov__content .card-links a {
  font-size: 0.88rem;
  padding: 0.15rem 0;
}

.card-ov__content .card-rule {
  margin: 0.85rem 0;
}

/* Dim page behind open card */
.card-ov-active .section-main,
.card-ov-active .section-footer,
.card-ov-active .cave-nav {
  filter: brightness(0.5);
  transition: filter 0.25s ease;
}

/* ── Map overlay ── */
.map-ov {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.map-ov--open {
  opacity: 1;
  pointer-events: all;
}

.map-ov__back {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 1, 0.75);
  cursor: pointer;
}

.map-ov__panel {
  position: relative;
  z-index: 1;
  width: min(88vw, 1260px);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 6px;
  border: 2px solid rgba(240, 176, 48, 0.22);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.9);
  background: #070503;
  transform: scale(0.95) translateY(16px);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.map-ov--open .map-ov__panel {
  transform: scale(1) translateY(0);
}

.map-ov__close {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  z-index: 10;
  background: rgba(20, 10, 3, 0.92);
  border: 1px solid rgba(240, 176, 48, 0.28);
  color: rgba(240, 176, 48, 0.65);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.map-ov__close:hover {
  color: var(--gold);
  border-color: rgba(240, 176, 48, 0.55);
}

.map-ov__inner {
  display: block;
}

.map-ov__inner svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Active room in overlay */
.room--active .chamber {
  filter:
    brightness(2.1)
    drop-shadow(0 0 8px rgba(255, 220, 60, 1.0))
    drop-shadow(0 0 26px rgba(255, 170, 30, 0.85)) !important;
}

.room--active .room-label { fill: #fff8b0 !important; }

/* Dim page content while map is open */
.map-ov-active .section-main,
.map-ov-active .section-footer {
  filter: brightness(0.55);
  transition: filter 0.3s ease;
}

.map-ov-active .cave-nav {
  filter: brightness(0.55);
  transition: filter 0.3s ease;
}

/* ── Footer ── */
.section-footer {
  text-align: center;
  padding: 1.75rem 2rem;
  border-top: 1px solid rgba(240,176,48,0.35);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(240,176,48,0.75);
}

.footer-sub {
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  margin-top: 0.45rem;
  color: rgba(240,176,48,0.6);
}

/* ── Back-to-top button ── */
#cc-top {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 200;
  width: 2.4rem;
  height: 2.4rem;
  background: rgba(20, 10, 3, 0.88);
  border: 1px solid rgba(240, 176, 48, 0.28);
  border-radius: 3px;
  color: rgba(240, 176, 48, 0.55);
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.2s, border-color 0.2s;
  pointer-events: none;
  font-family: 'Josefin Sans', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cc-top.cc-top--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#cc-top:hover {
  color: var(--gold);
  border-color: rgba(240, 176, 48, 0.55);
  background: rgba(30, 14, 4, 0.95);
}

/* ── On this day strip ── */
.otd-strip {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0 1.2rem;
  padding: 1rem 2rem;
  background: #100804;
  border-top: 1px solid rgba(240, 176, 48, 0.12);
  border-bottom: 1px solid rgba(240, 176, 48, 0.08);
}
.otd-label {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}
.otd-year {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(240, 176, 48, 0.5);
  white-space: nowrap;
}
.otd-text {
  font-size: 0.72rem;
  line-height: 1.55;
  color: rgba(242, 224, 184, 0.6);
}
@media (max-width: 600px) {
  .otd-strip {
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
  }
  .otd-text {
    grid-column: 1 / -1;
    margin-top: 0.4rem;
  }
}

/* ── PETSCII rain overlay (Konami easter egg) ── */
#cc-rain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #080604;
  cursor: pointer;
}
#cc-rain canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#cc-rain-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: clamp(1rem, 3vw, 1.6rem);
  font-weight: bold;
  color: #f0b030;
  text-shadow: 0 0 20px rgba(240, 176, 48, 0.7);
  letter-spacing: 0.15em;
  text-align: center;
  pointer-events: none;
  text-transform: uppercase;
}
#cc-rain-msg span {
  font-size: 0.45em;
  color: rgba(240, 176, 48, 0.55);
  margin-top: 0.8em;
  letter-spacing: 0.3em;
}

/* ── SYS 64738 reboot overlay ── */
#cc-reboot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #080604;
  display: flex;
  align-items: flex-start;
  padding: 3rem 2rem;
}
#cc-reboot-screen {
  font-family: monospace;
  font-size: clamp(0.75rem, 2vw, 1rem);
  color: #6bf;
  line-height: 1.7;
  white-space: pre;
}
.cc-reboot-blink {
  animation: cc-blink 0.8s step-end infinite;
}
@keyframes cc-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Related content nav ── */
.related-nav {
  margin: 2.5rem 2rem 0;
  padding: 1.1rem 1.5rem;
  background: rgba(8, 6, 4, 0.85);
  border: 1px solid rgba(240, 176, 48, 0.35);
  border-radius: 3px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}
.related-nav__label {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(240, 176, 48, 0.75);
  white-space: nowrap;
  flex-shrink: 0;
}
.related-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  list-style: none;
}
.related-nav__links a {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(240, 176, 48, 0.4);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}
.related-nav__links a:hover {
  color: #fff4a0;
  border-color: rgba(240, 176, 48, 0.8);
}

/* ── prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  #cc-top { transition: none; }
}
