@import url("reset.css");
@import url("variables.css");
@import url("nav.css");

html {
  background-color: var(--abyss);
  background-image: url("bg_sea_chart.jpg");
  background-size: auto;
  background-repeat: repeat;
  font-family: var(--font-family);
  color: var(--ink);
}

body {
  width: min(58rem, 100% - 2rem);
  margin: 4rem auto;
  padding: 3rem 3.5rem 2.5rem;
  border: 1px solid var(--brass);
  outline: 1px solid var(--brass);
  outline-offset: 6px;
  background-color: var(--fog);
  background-image: url("fg_sea_chart.jpg");
  background-size: auto;
  background-repeat: repeat;
  position: relative;
  font-size: 1.3rem;
  line-height: 1.6;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

/* Strip the global ornament and the previous gold scrollwork */
body::before,
body::after {
  content: none;
  background-image: none;
}

h1, h2 {
  font-family: var(--font-family-headers);
  color: var(--rust);
  margin-top: 0;
  letter-spacing: 0.04em;
  font-weight: 400;
}
h1 {
  font-size: 3.5rem;
  text-align: center;
  margin: 0.25rem 0 0;
  line-height: 1.05;
}
h2 { font-size: 2rem; }

/* Subtitle in IM Fell English italic */
section#main > h1 + div.line-block {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 2rem;
  text-align: center;
  color: var(--ink);
  margin: 0.75rem auto 0;
  max-width: 46rem;
}

body > section > p {
  margin: 0 0 1.1rem;
}

/* Centered, size-capped content images (excludes the decorative dragons,
   which are absolutely positioned with their own display rules).
   max-width clamps to the parent on narrow viewports so the image never
   overflows the parchment's right padding. */
section#main > p > img:not(.dragon) {
  display: block;
  margin: 0.5rem auto 1.75rem;
  max-width: min(20rem, 100%);
  height: auto;
}

a,
a:visited {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--verdigris);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a:hover,
a:focus {
  color: var(--rust);
  text-decoration-color: var(--rust);
  text-decoration-thickness: 2px;
}

div.cta {
  text-align: center;
  margin: 2.5rem 0 0.5rem;
}
div.cta a,
div.cta a:visited {
  display: inline-block;
  padding: 0.85rem 2.25rem;
  background-color: var(--rust);
  color: var(--fog);
  font-family: var(--font-family-headers);
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  text-decoration: none;
  border: 1px solid var(--brass);
}
div.cta a:hover,
div.cta a:focus {
  background-color: var(--ink);
  color: var(--fog);
  text-decoration: none;
}
div.cta a:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 4px;
}

div.index > ul {
  padding: 0;
  justify-content: center;
  list-style: none;
  gap: 0.25rem;
}
div.index > ul li a,
div.index > ul li a:visited {
  margin-top: 0.25rem;
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background-color: var(--rust);
  color: var(--fog);
  text-decoration: none;
  border: medium;
  border-radius: 0;
  cursor: pointer;
}
section.level1 > div.index ul {
  margin: 0;
  display: flex;
}
section.level2 > div.index ul {
  column-width: 25rem;
  column-gap: 2rem;
  li { break-inside: avoid-column; }
  li a, li a:visited { width: 20rem; }
}

h1.invisible { display: none; }

/* Decorative dragons with tiered fallback positioning by viewport width:
   - ≥ 1100px (tier 1): perched on the body's top-left and bottom-right
     corners, overlapping past the body padding into corner whitespace.
   - ≥ 32rem  (tier 2): both sit side-by-side below the body, aligned to
     its bottom-left and bottom-right corners — no overlap of body.
   - ≥ 15rem  (tier 3): both stacked vertically below the body — the
     left dragon (531) directly under the body on the left side, the
     right dragon (579) under it on the right side.
   - narrower than 15rem: both hidden. */
img.dragon {
  display: none;
  position: absolute;
  width: 13rem;
  height: auto;
  pointer-events: none;
  z-index: 10;
  margin: 0;
}

/* Tier 3 — stacked vertically below body, left dragon on left, right on right. */
@media (min-width: 15rem) {
  img.dragon-tl {
    display: block;
    top: calc(100% + 1rem);
    left: 0;
  }
  img.dragon-br {
    display: block;
    top: calc(100% + 15rem); /* 1rem gap + 13rem dragon-tl + 1rem gap */
    right: 0;
  }
}

/* Tier 2 — break the stack: right dragon moves up alongside the left. */
@media (min-width: 32rem) {
  img.dragon-br {
    top: calc(100% + 1rem);
  }
}

/* Tier 1 — both leap up to the body's diagonal corners with overlap. */
@media (min-width: 1100px) {
  img.dragon-tl {
    top: -2.5rem;
    left: auto;
    right: calc(100% - 8rem);
  }
  img.dragon-br {
    top: auto;
    bottom: -2.5rem;
    right: auto;
    left: calc(100% - 8rem);
  }
}

@media (max-width: 640px) {
  body {
    margin: 1.5rem auto;
    padding: 2rem 1.5rem;
  }
  h1 { font-size: 2.5rem; }
  section#main > h1 + p { font-size: 1.25rem; }
}
