/* ==========================================================================
   Base Styles — Reset, Typography, Mobile-First Responsive Layout
   ========================================================================== */

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

[hidden] {
  display: none !important;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
  background-color: var(--leather-base);
}

/* Fixed patina leather texture — persists across SPA page swaps */
body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-body);
  position: relative;
  isolation: isolate;
  background: transparent;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--leather-base);
  background-image: var(--leather-texture-tint), var(--leather-texture-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--page-overlay), url('../images/colour-dragon-dice-small.webp');
  background-position: center, var(--page-dragon-position);
  background-size: auto, var(--page-dragon-size);
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--color-heading);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover,
a:focus-visible {
  color: var(--color-accent-hover);
}

ul,
ol {
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-heading);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  font-weight: 600;
  margin-bottom: var(--space-md);
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }

p {
  margin-bottom: var(--space-md);
}

p:last-child {
  margin-bottom: 0;
}

strong {
  font-weight: 600;
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.site-main {
  min-height: calc(100vh - var(--header-height));
  padding-block: var(--space-2xl);
}

.site-main.page-enter {
  opacity: 0;
  transform: translateY(12px);
}

.site-main.page-enter--active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.page-content {
  padding-block: var(--space-xl);
  min-height: calc(100vh - var(--header-height));
}

.section {
  margin-bottom: var(--space-2xl);
}

/* ---- Footer ---- */
.site-footer {
  border-top: var(--border-width) solid var(--color-border);
  padding: var(--space-lg) var(--container-padding);
  text-align: center;
  background: var(--color-surface);
}

.site-footer p {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-body-muted);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}

/* ---- Shared page chrome ---- */
.page-header,
.page-section > .container > .page-title {
  text-align: center;
  margin-bottom: var(--space-2xl);
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.page-header h1,
.page-title {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: var(--space-sm);
}

.page-header p,
.page-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-body-muted);
  max-width: 36rem;
  margin-inline: auto;
  margin-bottom: 0;
}

.page-header::after,
.page-section > .container > .page-title::after {
  content: '';
  display: block;
  width: 3rem;
  height: 2px;
  margin: var(--space-lg) auto 0;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
}

/* ---- Utility Classes ---- */
.text-center { text-align: center; }

.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Responsive ---- */
@media (max-width: 767px) {
  body::before,
  body::after {
    background-attachment: scroll;
  }
}

@media (min-width: 768px) {
  :root {
    --font-size-h1: 3rem;
    --font-size-h2: 2.25rem;
    --font-size-h3: 1.625rem;
    --container-padding: var(--space-lg);
    --header-height: 4.75rem;
    --leather-texture-image: url('../images/old-leather-landscape.webp');
  }

  body::after {
    background-position: center, var(--page-dragon-position);
    background-size: auto, var(--page-dragon-size);
    background-attachment: fixed;
  }

  .site-main {
    padding-block: var(--space-3xl);
  }
}

@media (min-width: 1024px) {
  :root {
    --font-size-h1: 3.25rem;
    --container-padding: var(--space-xl);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  body::before,
  body::after {
    background-attachment: scroll;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .site-main.page-enter {
    opacity: 1;
    transform: none;
  }
}
