@layer reset, tokens, base, layout, components, utilities;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  * {
    margin: 0;
  }

  body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

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

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

  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    overflow-wrap: break-word;
  }

  #root,
  #__next {
    isolation: isolate;
  }
}

@layer tokens {
  @font-face {
    font-family: "Paytone One";
    src: url("../fonts/paytone-one-latin.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
  }

  :root {
    --font-primary: "Paytone One", system-ui, sans-serif;
    --font-body: system-ui, -apple-system, sans-serif;

    --space-xs: clamp(0.5rem, 1vw, 0.75rem);
    --space-sm: clamp(0.75rem, 2vw, 1rem);
    --space-md: clamp(1rem, 3vw, 1.5rem);
    --space-lg: clamp(1.5rem, 4vw, 2rem);
    --space-xl: clamp(2rem, 6vw, 3rem);
    --space-2xl: clamp(3rem, 8vw, 4rem);

    --text-xs: clamp(0.75rem, 2vw, 0.875rem);
    --text-sm: clamp(0.875rem, 2.5vw, 1rem);
    --text-base: clamp(1rem, 3vw, 1.125rem);
    --text-lg: clamp(1.125rem, 3.5vw, 1.25rem);
    --text-xl: clamp(1.25rem, 4vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 5vw, 2rem);
    --text-3xl: clamp(2rem, 6vw, 2.5rem);
    --text-4xl: clamp(2.5rem, 8vw, 3.5rem);

    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    color-scheme: light dark;
  }

  [data-theme="light"] {
    --ink: #141218;
    --paper: #f7f4ef;
    --ember: #c45508;
    --moss: #2f6e4f;
    --slate: #3b3b4f;
  }

  [data-theme="dark"] {
    --paper: #1a1a1a;
    --ink: #f7f4ef;
    --ember: #c45508;
    --moss: #2f6e4f;
    --slate: #6b7280;
  }
}

@layer base {
  html {
    scroll-behavior: smooth;
  }

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

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

  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--ink);
    background-color: var(--paper);
    transition: background-color 0.3s ease, color 0.3s ease;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--font-primary);
    line-height: 1.2;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--text-4xl);
  }
  h2 {
    font-size: var(--text-3xl);
  }
  h3 {
    font-size: var(--text-2xl);
  }
  h4 {
    font-size: var(--text-xl);
  }
  h5 {
    font-size: var(--text-lg);
  }
  h6 {
    font-size: var(--text-base);
  }

  p,
  li {
    text-wrap: pretty;
    max-width: 65ch;
  }

  a {
    color: var(--ember);
    text-decoration: underline;
    text-decoration-thickness: 0.125em;
    text-underline-offset: 0.25em;
    transition: color 0.2s ease;
  }

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

  a:focus-visible {
    outline: 2px solid var(--ember);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  img {
    height: auto;
  }

  svg {
    fill: currentColor;
  }
}

@layer layout {
  .dw-shell {
    max-width: min(90rem, calc(100vw - var(--space-md)));
    margin-inline: auto;
    padding-inline: var(--space-md);
  }

  .dw-grid {
    display: grid;
    gap: var(--space-lg);
  }

  .dw-grid-features {
    grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  }

  .dw-grid-bestiary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
    gap: var(--space-md);
  }

  @container (min-width: 48rem) {
    .dw-grid-bestiary {
      display: subgrid;
      grid-column: 1 / -1;
      grid-template-columns: subgrid;
    }
  }

  .dw-skip {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    z-index: 1000;
    padding: var(--space-xs) var(--space-sm);
    background: var(--ember);
    color: var(--paper);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    transform: translateY(-100%);
    transition: transform 0.2s ease;
  }

  .dw-skip:focus {
    transform: translateY(0);
  }

  .dw-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;
  }
}

@layer components {
  .dw-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--paper);
    border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
    backdrop-filter: blur(8px);
  }

  .dw-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: var(--space-sm);
  }

  .dw-logo {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    text-decoration: none;
    color: var(--ink);
  }

  .dw-logo-text {
    font-family: var(--font-primary);
    font-size: var(--text-lg);
    font-weight: 400;
  }

  .dw-nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    border-radius: var(--radius-md);
  }

  .dw-nav-toggle:hover,
  .dw-nav-toggle:focus-visible {
    background: color-mix(in srgb, var(--ink) 5%, transparent);
  }

  .dw-nav-menu {
    display: flex;
    list-style: none;
    padding: 0;
    gap: var(--space-md);
  }

  .dw-nav-menu a {
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease;
  }

  .dw-nav-menu a:hover,
  .dw-nav-menu a:focus-visible {
    background: color-mix(in srgb, var(--ember) 10%, transparent);
  }

  .dw-nav-menu a[aria-current="page"] {
    background: var(--ember);
    color: var(--paper);
  }

  @media (max-width: 48rem) {
    .dw-nav-toggle {
      display: block;
    }

    .dw-nav-menu {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background: var(--paper);
      border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
      border-top: none;
      flex-direction: column;
      padding: var(--space-md);
      transform: translateY(-100%);
      opacity: 0;
      visibility: hidden;
      transition: all 0.2s ease;
    }

    .dw-header.dw-nav-open .dw-nav-menu {
      transform: translateY(0);
      opacity: 1;
      visibility: visible;
    }
  }

  .dw-theme-toggle {
    background: none;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    border-radius: var(--radius-md);
    color: var(--ink);
  }

  .dw-theme-toggle:hover,
  .dw-theme-toggle:focus-visible {
    background: color-mix(in srgb, var(--ink) 5%, transparent);
  }

  .dw-hero {
    padding-block: var(--space-2xl);
    background: linear-gradient(
      135deg,
      color-mix(in srgb, var(--moss) 5%, transparent) 0%,
      color-mix(in srgb, var(--ember) 3%, transparent) 100%
    );
  }

  .dw-hero .dw-shell {
    display: grid;
    gap: var(--space-xl);
    align-items: center;
  }

  @container (min-width: 48rem) {
    .dw-hero .dw-shell {
      grid-template-columns: 1fr 1fr;
    }
  }

  .dw-hero-title {
    margin-bottom: var(--space-md);
  }

  .dw-hero-subtitle {
    font-size: var(--text-lg);
    color: var(--slate);
    margin-bottom: var(--space-lg);
    max-width: none;
  }

  .dw-hero-actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
  }

  .dw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 2.75rem;
  }

  .dw-btn-primary {
    background: var(--ember);
    color: var(--paper);
    box-shadow: var(--shadow-md);
  }

  .dw-btn-primary:hover,
  .dw-btn-primary:focus-visible {
    background: color-mix(in srgb, var(--ember) 90%, black);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }

  .dw-btn-secondary {
    background: transparent;
    color: var(--ink);
    border: 2px solid var(--ink);
  }

  .dw-btn-secondary:hover,
  .dw-btn-secondary:focus-visible {
    background: var(--ink);
    color: var(--paper);
  }

  .dw-btn-full {
    width: 100%;
  }

  .dw-section-title {
    text-align: center;
    margin-bottom: var(--space-lg);
  }

  .dw-section-intro {
    text-align: center;
    font-size: var(--text-lg);
    color: var(--slate);
    margin-bottom: var(--space-xl);
    max-width: 60ch;
    margin-inline: auto;
  }

  .dw-features {
    padding-block: var(--space-2xl);
  }

  .dw-feature-card {
    background: var(--paper);
    border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    container-type: inline-size;
  }

  .dw-feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }

  .dw-card-icon {
    margin-bottom: var(--space-md);
    color: var(--ember);
  }

  .dw-card-title {
    margin-bottom: var(--space-sm);
    color: var(--ink);
  }

  .dw-card-text {
    color: var(--slate);
    margin-bottom: var(--space-md);
  }

  .dw-feature-list {
    list-style: none;
    padding: 0;
  }

  .dw-feature-list li {
    position: relative;
    padding-left: var(--space-md);
    margin-bottom: var(--space-xs);
    color: var(--slate);
  }

  .dw-feature-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--ember);
    font-weight: bold;
  }

  .dw-bestiary {
    padding-block: var(--space-2xl);
    background: color-mix(in srgb, var(--moss) 3%, transparent);
    container-type: inline-size;
  }

  .dw-creature-card {
    background: var(--paper);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
  }

  .dw-creature-card:hover {
    transform: scale(1.02);
  }

  .dw-creature-card img {
    width: 100%;
    height: 12rem;
    object-fit: cover;
  }

  .dw-creature-card figcaption {
    padding: var(--space-md);
  }

  .dw-creature-card h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-xs);
    color: var(--ink);
  }

  .dw-creature-card p {
    color: var(--slate);
    font-size: var(--text-sm);
  }

  .dw-timeline {
    padding-block: var(--space-2xl);
  }

  .dw-timeline-list {
    max-width: 50rem;
    margin-inline: auto;
  }

  .dw-timeline-entry {
    display: grid;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-left: 3px solid var(--ember);
    margin-bottom: var(--space-lg);
    position: relative;
  }

  .dw-timeline-entry::before {
    content: "";
    position: absolute;
    left: -0.5rem;
    top: var(--space-lg);
    width: 1rem;
    height: 1rem;
    background: var(--ember);
    border-radius: 50%;
  }

  .dw-timeline-date {
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    color: var(--ember);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .dw-timeline-content h3 {
    margin-bottom: var(--space-sm);
    color: var(--ink);
  }

  .dw-timeline-content p {
    color: var(--slate);
  }

  .dw-form-section {
    padding-block: var(--space-2xl);
    background: color-mix(in srgb, var(--ember) 3%, transparent);
  }

  .dw-form-container {
    max-width: 40rem;
    margin-inline: auto;
  }

  .dw-form-intro {
    text-align: center;
    margin-bottom: var(--space-xl);
  }

  .dw-form-description {
    font-size: var(--text-lg);
    color: var(--slate);
    max-width: none;
  }

  .dw-form {
    background: var(--paper);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
  }

  .dw-form-group {
    margin-bottom: var(--space-lg);
  }

  .dw-form-label {
    display: block;
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    color: var(--ink);
    margin-bottom: var(--space-xs);
  }

  .dw-form-input,
  .dw-form-textarea {
    width: 100%;
    padding: var(--space-sm);
    border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: border-color 0.2s ease;
  }

  .dw-form-input:focus,
  .dw-form-textarea:focus {
    outline: none;
    border-color: var(--ember);
  }

  .dw-form-input:invalid,
  .dw-form-textarea:invalid {
    border-color: #dc2626;
  }

  .dw-form-error {
    color: #dc2626;
    font-size: var(--text-xs);
    margin-top: var(--space-xs);
    min-height: 1.25rem;
  }

  .dw-form-help {
    color: var(--slate);
    font-size: var(--text-xs);
    margin-top: var(--space-xs);
  }

  .dw-footer {
    background: var(--ink);
    color: var(--paper);
    padding-block: var(--space-2xl) var(--space-lg);
  }

  .dw-footer-content {
    display: grid;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
  }

  @container (min-width: 48rem) {
    .dw-footer-content {
      grid-template-columns: 1fr auto;
      align-items: start;
    }
  }

  .dw-footer .dw-logo-text {
    color: var(--paper);
  }

  .dw-footer-tagline {
    color: color-mix(in srgb, var(--paper) 70%, transparent);
    margin-top: var(--space-sm);
  }

  .dw-footer-links {
    display: flex;
    list-style: none;
    padding: 0;
    gap: var(--space-lg);
    flex-wrap: wrap;
  }

  .dw-footer-links a {
    color: var(--paper);
    text-decoration: none;
  }

  .dw-footer-links a:hover,
  .dw-footer-links a:focus-visible {
    color: var(--ember);
  }

  .dw-footer-bottom {
    border-top: 1px solid color-mix(in srgb, var(--paper) 20%, transparent);
    padding-top: var(--space-lg);
    text-align: center;
  }

  .dw-copyright {
    color: color-mix(in srgb, var(--paper) 70%, transparent);
    font-size: var(--text-sm);
  }
}

@layer utilities {
  .dw-text-center {
    text-align: center;
  }
  .dw-text-balance {
    text-wrap: balance;
  }
  .dw-text-pretty {
    text-wrap: pretty;
  }

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

@media print {
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
  }

  .dw-nav-toggle,
  .dw-form-section,
  .dw-hero-actions {
    display: none !important;
  }

  .dw-header {
    position: static;
    border-bottom: 2px solid black;
  }

  h1,
  h2,
  h3 {
    page-break-after: avoid;
  }

  .dw-feature-card,
  .dw-timeline-entry {
    page-break-inside: avoid;
  }
}
