:root {
  --bg: #faf7f0;
  --bg-alt: #f1ece0;
  --ink: #2b2a26;
  --ink-soft: #55534a;
  --accent: #5b7a8c;
  --accent-dark: #35505f;
  --gold: #c98f3a;
  --card-bg: #ffffff;
  --border: #e3dcc8;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(43, 42, 38, 0.08);
  font-size: 16px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.15; margin: 0 0 .5em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--accent-dark); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; color: var(--ink-soft); }
a { color: var(--accent-dark); }
strong { color: var(--ink); }

/* ---------- Nav ---------- */
#topnav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 247, 240, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1100px; margin: 0 auto; padding: .8rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-family: Georgia, serif; font-weight: bold; font-size: 1.25rem; color: var(--accent-dark); }
.brand-accent { color: var(--gold); }
#navLinks { list-style: none; display: flex; gap: 1.4rem; margin: 0; padding: 0; }
#navLinks a { text-decoration: none; color: var(--ink-soft); font-size: .95rem; }
#navLinks a:hover { color: var(--accent-dark); }
#navToggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--ink); }

@media (max-width: 760px) {
  #navToggle { display: block; }
  #navLinks {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.2rem; gap: .9rem;
    display: none;
  }
  #navLinks.open { display: flex; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  min-height: 68vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; color: #fff;
}
.hero-sky { position: absolute; inset: 0; background: linear-gradient(180deg, #6d93ab 0%, #a9c3d1 55%, #d8e6e9 100%); }
.hero-mountains { position: absolute; inset: 0; width: 100%; height: 100%; }
.mtn-back { fill: #8fa9b8; opacity: .8; }
.mtn-mid { fill: #6e8b9c; opacity: .9; }
.mtn-front { fill: #4c6b7a; }
.hero-content { position: relative; z-index: 2; max-width: 760px; padding: 2rem 1.4rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; opacity: .9; margin-bottom: .6rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: .6rem; text-shadow: 0 2px 12px rgba(0,0,0,.25); }
.hero-sub { font-size: 1.05rem; opacity: .95; max-width: 620px; margin: 0 auto 1.6rem; }
.cta {
  display: inline-block; background: var(--gold); color: #2b2a26;
  padding: .7rem 1.5rem; border-radius: 999px; text-decoration: none;
  font-weight: 600; box-shadow: var(--shadow); transition: transform .15s ease;
}
.cta:hover { transform: translateY(-2px); }

/* ---------- Sections ---------- */
.section { max-width: 1100px; margin: 0 auto; padding: 4rem 1.4rem; }
.section.alt { background: var(--bg-alt); max-width: none; }
.section.alt > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.section.alt > *:not(.timeline):not(.rock-grid):not(.filter-bar) { }
.lede { max-width: 720px; font-size: 1.05rem; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-top: 2rem; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem 1.2rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .3rem;
}
.stat-num { font-family: Georgia, serif; font-size: 1.7rem; color: var(--accent-dark); font-weight: bold; }
.stat-label { color: var(--ink-soft); font-size: .9rem; }

/* ---------- Timeline ---------- */
.timeline { margin-top: 2rem; }
.timeline-track {
  display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .6rem; margin-bottom: 1.4rem;
  scrollbar-width: thin;
}
.timeline-dot {
  flex: 0 0 auto; cursor: pointer;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: .7rem 1rem; font-size: .85rem; color: var(--ink-soft);
  text-align: left; min-width: 150px; transition: all .15s ease;
}
.timeline-dot small { color: var(--accent); font-weight: 600; }
.timeline-dot.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
.timeline-dot.active small { color: var(--gold); }
.timeline-panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem 1.8rem; box-shadow: var(--shadow); min-height: 180px; }
.era-panel { display: none; animation: fadein .3s ease; }
.era-panel.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }

/* ---------- Cross section ---------- */
.xsection-wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.6rem; align-items: start; margin-top: 2rem; }
#xsection { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: #eaf3f7; }
.xlayer { cursor: pointer; transition: filter .15s ease, opacity .15s ease; }
.xlayer:hover, .xlayer.hovered { filter: brightness(1.08) saturate(1.3); }
.xlabel-title { font-family: Georgia, serif; font-size: 20px; fill: var(--accent-dark); }
.xsection-info {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow); min-height: 160px;
}
.xsection-hint { color: var(--ink-soft); font-style: italic; }
.xsection-info h4 { margin: 0 0 .4rem; color: var(--accent-dark); font-family: Georgia, serif; }
@media (max-width: 800px) { .xsection-wrap { grid-template-columns: 1fr; } }

/* ---------- Rock grid ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.6rem; margin-bottom: 2rem; }
.filter-btn {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 999px;
  padding: .45rem 1.1rem; cursor: pointer; font-size: .88rem; color: var(--ink-soft);
}
.filter-btn.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }

.rock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.4rem; }
.rock-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s ease;
}
.rock-card:hover { transform: translateY(-3px); }
.rock-card.hidden { display: none; }
.rock-swatch { height: 100px; }
.swatch-limestone { background: linear-gradient(135deg, #f4f1e6, #e2dbc0); }
.swatch-dolomite { background: linear-gradient(135deg, #e9e4d0, #cfc7a3); }
.swatch-marble { background: linear-gradient(135deg, #ffffff, #d7e2e5); }
.swatch-granite { background: linear-gradient(135deg, #f0d9e2, #c98fab); }
.swatch-quartzite { background: linear-gradient(135deg, #e6ebec, #b7c4c6); }
.swatch-volcanic { background: linear-gradient(135deg, #d97a4e, #8f4527); }
.swatch-ore { background: linear-gradient(135deg, #aab3c4, #565f70); }
.swatch-till { background: linear-gradient(135deg, #b9c4c8, #7c8a90); }
.rock-body { padding: 1.1rem 1.2rem 1.4rem; }
.rock-type-tag {
  display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); font-weight: 700; margin-bottom: .3rem;
}
.rock-summary { font-size: .92rem; margin-bottom: 0; }
.rock-detail { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.rock-card.open .rock-detail { max-height: 600px; margin-top: .8rem; }
.rock-detail p { font-size: .92rem; }

/* ---------- History ---------- */
.history-flex { display: grid; grid-template-columns: 1.3fr 1fr; gap: 2rem; margin-top: 2rem; align-items: start; }
.history-stats { display: flex; flex-direction: column; gap: .8rem; }
.history-stat {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem 1rem; font-size: .9rem; color: var(--ink-soft); box-shadow: var(--shadow);
}
.history-stat span { display: block; font-family: Georgia, serif; font-weight: bold; color: var(--accent-dark); font-size: 1.1rem; }
@media (max-width: 800px) { .history-flex { grid-template-columns: 1fr; } }

/* ---------- Quiz ---------- */
.quiz-app { margin-top: 2rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.8rem; box-shadow: var(--shadow); }
.quiz-progress { height: 6px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; margin-bottom: 1.6rem; }
.quiz-bar { height: 100%; width: 0%; background: var(--gold); transition: width .3s ease; }
.quiz-question h4 { font-family: Georgia, serif; color: var(--accent-dark); margin-bottom: 1rem; }
.quiz-options { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.2rem; }
.quiz-option {
  text-align: left; padding: .7rem 1rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); cursor: pointer; font-size: .95rem; color: var(--ink);
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.correct { background: #e4f3e6; border-color: #6fb583; }
.quiz-option.incorrect { background: #fbe6e4; border-color: #d98e86; }
.quiz-option[disabled] { cursor: default; }
.quiz-feedback { font-size: .9rem; color: var(--ink-soft); min-height: 1.4em; margin-bottom: 1rem; }
.quiz-next {
  background: var(--accent-dark); color: #fff; border: none; border-radius: 999px;
  padding: .6rem 1.4rem; cursor: pointer; font-size: .9rem;
}
.quiz-next:disabled { opacity: .4; cursor: not-allowed; }
.quiz-result { text-align: center; padding: 1rem 0; }
.quiz-result h3 { font-size: 1.6rem; }
.quiz-restart {
  margin-top: 1rem; background: var(--gold); border: none; border-radius: 999px;
  padding: .6rem 1.4rem; cursor: pointer; font-weight: 600;
}

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 2.4rem 1.4rem; color: var(--ink-soft); font-size: .82rem; border-top: 1px solid var(--border); max-width: 900px; margin: 0 auto; }
