:root {
  --paper: #f5f0e8;
  --paper-deep: #ede5d0;
  --card: #faf6ee;
  --ink: #3b2a1a;
  --muted: #7b654d;
  --gold: #c9a84c;
  --terracotta: #a0522d;
  --line: rgba(100, 74, 42, 0.22);
  --shadow: 0 18px 50px rgba(59, 42, 26, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Lora", Georgia, serif;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.2), rgba(59, 42, 26, 0.08) 72%, rgba(59, 42, 26, 0.14)),
    repeating-linear-gradient(35deg, rgba(201, 168, 76, 0.035) 0 2px, transparent 2px 8px),
    var(--paper);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.cover-page {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  color: #e8d5a3;
  background: #1a1208;
}

.cover-noise,
.cover-map,
.cover-vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cover-noise {
  opacity: 0.04;
}

.cover-noise rect {
  fill: #fff;
}

.cover-map {
  top: 50%;
  left: 50%;
  width: min(1180px, 120vw);
  height: auto;
  opacity: 0.06;
  transform: translate(-50%, -50%);
}

.cover-map path {
  fill: none;
  stroke: #e8d5a3;
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
}

.cover-vignette {
  background: radial-gradient(ellipse at center, transparent 30%, rgba(15, 8, 2, 0.85) 100%);
}

.cover-content {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: min(760px, calc(100vw - 36px));
  text-align: center;
  transform: translate(-50%, -50%);
}

.cover-rule {
  width: 60px;
  height: 1px;
  margin: 0 auto 24px;
  background: #c9a84c;
}

.cover-title {
  margin: 0 0 8px;
  color: #e8d5a3;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.02;
  text-transform: uppercase;
}

.cover-kicker {
  margin: 0 0 48px;
  color: #c9a84c;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.5rem, 4.4vw, 2rem);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cover-sentences {
  min-height: 180px;
}

.cover-sentence {
  max-width: 640px;
  margin: 0 auto 14px;
  color: #c9a84c;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(1.38rem, 2.1vw, 1.75rem);
  font-style: normal;
  line-height: 1.65;
  opacity: 0;
  text-align: center;
  transition: opacity 1.2s ease;
}

.cover-sentence.cover-visible {
  opacity: 1;
}

.cover-inline-link {
  display: inline;
  padding: 0 0 0 8px;
  color: #e8d5a3;
  font-family: "Times New Roman", Times, serif;
  font-size: inherit;
  font-weight: 700;
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.cover-scroll-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  z-index: 2;
  color: #c9a84c;
  font-family: "Lora", Georgia, serif;
  font-size: 0.81rem;
  letter-spacing: 0.2em;
  opacity: 0;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.cover-scroll-hint.cover-visible {
  animation: coverPulse 2s ease-in-out infinite;
}

@keyframes coverPulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

#scroll-story {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  background: #140e06;
}

.story-sticky-map {
  position: sticky;
  top: 0;
  display: grid;
  width: 50%;
  height: 100vh;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.14), transparent 48%),
    repeating-linear-gradient(35deg, rgba(201, 168, 76, 0.035) 0 2px, transparent 2px 8px),
    #f5f0e8;
  border-left: 1px solid rgba(100, 74, 42, 0.22);
}

.story-sticky-map::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(ellipse at center, transparent 42%, rgba(59, 42, 26, 0.14) 100%);
}

#storyMap {
  position: relative;
  z-index: 1;
  width: min(112%, 920px);
  height: auto;
}

.story-sphere {
  fill: rgba(214, 201, 169, 0.34);
  stroke: rgba(160, 82, 45, 0.18);
  stroke-width: 1;
}

.story-graticule path {
  fill: none;
  stroke: rgba(160, 82, 45, 0.16);
  stroke-width: 0.8;
}

.story-country-layer path {
  fill: #d9c89d;
  opacity: 1;
  stroke: rgba(59, 42, 26, 0.42);
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
  transition: fill 260ms ease, opacity 260ms ease, filter 260ms ease;
}

.story-country-layer path.story-country-active {
  fill: #e3d3aa;
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(201, 168, 76, 0.38));
}

.story-map-marker-ring {
  fill: none;
  stroke: #c9a84c;
  stroke-width: 4;
  animation: storyMarkerPulse 2s ease-in-out infinite;
}

.story-map-marker-dot {
  fill: var(--story-marker-color, #c9a84c);
  stroke: #faf6ee;
  stroke-width: 3;
}

.story-map-label {
  position: absolute;
  right: clamp(18px, 5vw, 72px);
  bottom: clamp(28px, 7vh, 80px);
  z-index: 2;
  color: #3b2a1a;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 3.2rem);
  text-align: right;
}

@keyframes storyMarkerPulse {
  0%,
  100% {
    opacity: 0.45;
    r: 15;
  }
  50% {
    opacity: 1;
    r: 22;
  }
}

.story-chapters {
  width: 50%;
}

.story-chapter {
  position: relative;
  min-height: 100vh;
  padding: 80px 60px;
  overflow: hidden;
  color: #e8d5a3;
  background: var(--story-tint, #140e06);
  border-top: 1px solid rgba(201, 168, 76, 0.2);
}

.story-chapter-bg {
  position: absolute;
  inset: 0;
  opacity: 0.1;
  background:
    radial-gradient(circle at 30% 20%, rgba(232, 213, 163, 0.25), transparent 22%),
    linear-gradient(135deg, var(--story-tint, #140e06), #140e06);
}

.story-chapter::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(20, 14, 6, 0.34);
}

.story-chapter-inner {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: calc(100vh - 160px);
  align-items: center;
  gap: 28px;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.story-chapter.story-active .story-chapter-inner {
  opacity: 1;
  transform: translateY(0);
}

.story-copy {
  width: 100%;
  max-width: 720px;
}

.story-copy h2 {
  margin: 0;
  color: #e8d5a3;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.5rem, 5vw, 3rem);
  line-height: 1.05;
}

.story-rule {
  width: 72px;
  height: 1px;
  margin: 18px 0 12px;
  background: #c9a84c;
}

.story-era {
  margin: 0 0 24px;
  color: #c9a84c;
  font-style: italic;
  font-size: 0.9rem;
}

.story-intro {
  margin: 0 0 22px;
  color: #d4c4a0;
  font-size: 1.05rem;
  line-height: 1.75;
}

.story-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.story-tag {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 10px;
  color: #e8d5a3;
  font-size: 0.82rem;
  border: 1px solid rgba(201, 168, 76, 0.34);
  border-radius: 999px;
  background: rgba(232, 213, 163, 0.06);
}

.story-explore {
  min-height: 44px;
  padding: 10px 16px;
  color: #140e06;
  font-weight: 700;
  background: #c9a84c;
  border: 1px solid rgba(232, 213, 163, 0.5);
  border-radius: 8px;
}

.chapter-even .story-chapter-inner {
  flex-direction: row-reverse;
  text-align: right;
}

.chapter-even .story-rule {
  margin-left: auto;
}

.chapter-even .story-tags {
  justify-content: flex-end;
}

.story-to-map-transition {
  display: grid;
  height: 120px;
  place-items: center;
  color: #c9a84c;
  text-align: center;
  background: linear-gradient(#140e06, #f5f0e8);
}

.story-to-map-transition p {
  margin: 0 0 6px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.story-to-map-transition span {
  display: block;
  font-size: 1.5rem;
}

@media (max-width: 900px) {
  #scroll-story {
    display: block;
  }

  .story-sticky-map,
  .story-chapters {
    width: 100%;
  }

  .story-sticky-map {
    height: 54vh;
    border-left: 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.18);
  }

  .story-chapter {
    padding: 56px 24px;
  }

  .story-chapter-inner,
  .chapter-even .story-chapter-inner {
    flex-direction: column;
    align-items: flex-start;
    min-height: auto;
    text-align: left;
  }

  .chapter-even .story-rule {
    margin-left: 0;
  }

  .chapter-even .story-tags {
    justify-content: flex-start;
  }
}

.site-header {
  padding: 34px clamp(18px, 5vw, 72px) 24px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--terracotta);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.5rem);
}

h1 span {
  display: block;
}

.map-label {
  margin: 8px 0 0;
  color: rgba(90, 53, 28, 0.78);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.subtitle {
  max-width: min(980px, calc(100vw - 40px));
  margin: 8px auto 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: nowrap;
}

#regionSubtitle {
  max-width: 720px;
  margin: 12px auto 0;
  color: var(--muted);
  line-height: 1.7;
}

.atlas-shell {
  position: relative;
  min-height: 620px;
  overflow: hidden;
}

.map-stage {
  position: relative;
  min-height: 720px;
  padding: clamp(12px, 2vw, 28px);
}

.map-stage::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle at center, transparent 48%, rgba(59, 42, 26, 0.14));
}

.map-toolbar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

#worldMap {
  position: relative;
  z-index: 2;
  display: block;
  width: min(1480px, 112%);
  height: auto;
  min-height: 520px;
  margin: 0 auto;
  transform-origin: center center;
  transition: transform 420ms ease;
}

.atlas-shell.region-open #worldMap {
  animation: mapFocusLeft 620ms cubic-bezier(0.2, 0.72, 0.2, 1) forwards;
}

#worldMap.map-rotating {
  filter: drop-shadow(0 14px 24px rgba(59, 42, 26, 0.16));
}

@keyframes mapFocusLeft {
  0% {
    transform: translateX(0) scale(1);
  }
  55% {
    transform: translateX(-12vw) scale(1.08);
  }
  100% {
    transform: translateX(-16vw) scale(1.16);
  }
}

.graticule path {
  fill: none;
  stroke: rgba(160, 82, 45, 0.16);
  stroke-width: 1;
}

.sphere {
  fill: rgba(214, 201, 169, 0.34);
  stroke: rgba(160, 82, 45, 0.18);
  stroke-width: 1.2;
}

.countries path {
  fill: #d9c89d;
  stroke: rgba(59, 42, 26, 0.42);
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
}

.countries path:hover {
  fill: #e3d3aa;
}

.countries path.region-country-fill {
  opacity: 1;
}

.countries path.region-country-fill:hover {
  filter: saturate(1.06);
}

.marker {
  transform-box: fill-box;
  transform-origin: center;
}

.marker button,
.marker circle {
  cursor: pointer;
}

.marker-dot {
  stroke: #faf6ee;
  stroke-width: 3;
  animation: pulse 2.4s ease-in-out infinite;
}

.marker-ring {
  fill: none;
  stroke: var(--gold);
  stroke-width: 0;
  opacity: 0;
}

.marker.active .marker-ring {
  stroke-width: 5;
  opacity: 1;
}

.marker.active .marker-dot {
  r: 10;
}

@keyframes pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(201, 168, 76, 0));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(201, 168, 76, 0.9));
  }
}

.map-hint {
  position: relative;
  z-index: 2;
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: clamp(420px, 32vw, 640px);
  height: 100vh;
  padding: 24px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--sidebar-region-soft, #ede5d0) 46%, #ede5d0), #ede5d0 62%),
    var(--paper-deep);
  border-left: 3px solid color-mix(in srgb, var(--sidebar-region-color, #c9a84c) 70%, #fff);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 260ms ease, width 260ms ease;
}

.sidebar.has-sidebar-bg {
  background:
    linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.72)),
    var(--sidebar-bg-image),
    linear-gradient(145deg, color-mix(in srgb, var(--sidebar-region-soft, #ede5d0) 46%, #ede5d0), #ede5d0 62%);
  background-position: center;
  background-size: cover;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header,
.modal-header,
.form-actions,
.card-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sidebar-header {
  position: relative;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.sidebar-bg-hint {
  display: inline-block;
  margin-top: 8px;
  color: rgba(59, 42, 26, 0.46);
  font-size: 0.76rem;
}

.sidebar-bg-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.practice-list {
  flex: 1;
  min-height: 0;
  padding: 18px 2px;
  overflow-y: auto;
}

.sidebar-back-link {
  width: 100%;
  min-height: 40px;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 700;
  background: rgba(250, 246, 238, 0.76);
  border: 1px solid rgba(160, 82, 45, 0.28);
  border-radius: 8px;
}

.sidebar-back-link[hidden] {
  display: none;
}

.practice-card {
  width: 100%;
  margin-bottom: 12px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  background: var(--card);
  border: 1px solid rgba(201, 168, 76, 0.58);
  border-radius: 8px;
  box-shadow: 0 7px 18px rgba(59, 42, 26, 0.08);
}

.practice-summary {
  width: 100%;
  padding-bottom: 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.practice-summary h3 {
  font-size: 1.15rem;
}

.time-period {
  display: inline-block;
  margin: 8px 0;
  color: var(--terracotta);
  font-weight: 700;
  font-size: 0.88rem;
}

.one-line,
.detail-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.practice-detail {
  display: block;
  margin-top: 16px;
}

.practice-card.expanded .practice-detail {
  display: block;
}

.practice-image-panel {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.practice-image-frame {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 150px;
  place-items: center;
  overflow: hidden;
  background:
    repeating-linear-gradient(45deg, rgba(201, 168, 76, 0.08) 0 8px, transparent 8px 16px),
    rgba(237, 229, 208, 0.5);
  border: 1px dashed rgba(160, 82, 45, 0.42);
  border-radius: 8px;
  cursor: pointer;
}

.practice-image-frame img {
  display: block;
  width: 100%;
  max-height: 230px;
  object-fit: cover;
}

.practice-image-frame.has-image {
  border-style: solid;
}

.practice-image-frame.has-image::after {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 8px;
  color: #fffaf1;
  font-size: 0.76rem;
  font-weight: 700;
  content: "Replace";
  background: rgba(59, 42, 26, 0.68);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.practice-image-frame.has-image:hover::after {
  opacity: 1;
}

.image-placeholder {
  color: rgba(123, 101, 77, 0.64);
  font-size: 0.92rem;
  font-weight: 700;
}

.image-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.image-upload {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(250, 246, 238, 0.76);
  border: 1px solid rgba(160, 82, 45, 0.28);
  border-radius: 8px;
  cursor: pointer;
}

.image-url-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--ink);
  font-weight: 700;
}

.image-url-input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fffaf1;
  border: 1px solid rgba(59, 42, 26, 0.28);
  border-radius: 8px;
}

.image-source-text {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.detail-row {
  margin-bottom: 13px;
}

.detail-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

a {
  color: #6e3f20;
}

.primary-button,
.secondary-button,
.text-button,
.reset-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(160, 82, 45, 0.28);
}

.primary-button {
  width: 100%;
  padding: 10px 14px;
  color: #fffaf1;
  font-weight: 700;
  background: var(--terracotta);
}

.secondary-button,
.text-button,
.reset-button {
  padding: 9px 13px;
  color: var(--ink);
  background: rgba(250, 246, 238, 0.76);
}

.icon-button {
  flex: 0 0 auto;
  width: 40px;
  color: var(--ink);
  font-weight: 700;
  background: rgba(250, 246, 238, 0.86);
}

.card-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.card-actions .icon-button {
  width: 36px;
  min-height: 36px;
}

.site-footer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.footer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.creator-credit {
  color: rgba(123, 101, 77, 0.38);
  font-size: 0.78rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(59, 42, 26, 0.38);
}

.modal.open {
  display: flex;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  background: var(--paper);
  border: 2px solid rgba(201, 168, 76, 0.62);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-form {
  margin-top: 18px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid rgba(59, 42, 26, 0.28);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fffaf1;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#subscribe-section {
  background: #1a1208;
  border-top: 1px solid rgba(201, 168, 76, 0.3);
  padding: 80px 40px;
  text-align: center;
}

.subscribe-inner {
  max-width: 560px;
  margin: 0 auto;
}

.subscribe-label {
  font-family: "Lora", serif;
  font-size: 11px;
  letter-spacing: 0.25em;
  color: #c9a84c;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.subscribe-title {
  font-family: "Playfair Display", serif;
  font-size: 32px;
  color: #e8d5a3;
  margin-bottom: 12px;
  font-weight: 400;
}

.subscribe-sub {
  font-family: "Lora", serif;
  font-size: 15px;
  color: #a89878;
  margin-bottom: 32px;
  line-height: 1.7;
}

.subscribe-btn {
  display: inline-block;
  padding: 14px 36px;
  border: 1px solid #c9a84c;
  color: #c9a84c;
  font-family: "Lora", serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: all 0.3s ease;
}

.subscribe-btn:hover {
  background: #c9a84c;
  color: #1a1208;
}

@media (max-width: 720px) {
  .site-header {
    text-align: left;
  }

  .subtitle {
    white-space: normal;
  }

  .map-stage {
    min-height: 500px;
    padding: 14px;
  }

  #worldMap {
    min-height: 330px;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 100vw;
  }

  .atlas-shell.region-open #worldMap {
    animation: mapFocusLeftMobile 420ms ease forwards;
  }

  @keyframes mapFocusLeftMobile {
    from {
      transform: translateX(0) scale(1);
    }
    to {
      transform: translateX(-8vw) scale(1.06);
    }
  }
}
