/*
 * main.css — Shieldwall Games
 *
 * Global shared stylesheet for all pages (homepage, mimir, ashborn).
 * Contains ONLY:
 *   1. @font-face declarations (Njord)
 *   2. Google Fonts @import
 *   3. CSS reset
 *   4. Base design tokens (:root)
 *   5. Semantic tokens (dark only)
 *   6. Element baselines (body, headings, type classes, links)
 *   7. Utility classes (surfaces, grain, rule)
 *   8. Site utilities (container, visually-hidden, skip-link, theme toggle, reveal)
 *   9. Smooth scroll media query
 *
 * Page-specific styles live in their own files:
 *   - mimir/styles/mimir.css
 *   - ashborn/styles/ashborn.css
 */

/* ==========================================================================
   1. @font-face — Njord (client-supplied)
   ========================================================================== */

@font-face {
    font-family: 'Njord';
    src: url('../assets/fonts/Njord-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Njord';
    src: url('../assets/fonts/Njord-Alternate.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   2. Google Fonts — Source Serif 4, Inter, JetBrains Mono
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,300;8..60,400;8..60,500;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

/* ==========================================================================
   3. CSS Reset
   ========================================================================== */

/* Use border-box for all elements */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Remove default margin and padding */
* {
    margin: 0;
    padding: 0;
}

/* Prevent font-size inflation on mobile */
html {
    -moz-text-size-adjust: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    font-size: 100%;
}

/* Images and media default to block and constrain to parent */
img,
picture,
svg,
video {
    display: block;
    max-width: 100%;
}

/* Form elements inherit font from parent */
input,
button,
textarea,
select {
    font: inherit;
}

/* Remove list styles on ul/ol with a list role */
ul[role='list'],
ol[role='list'] {
    list-style: none;
}

/* Prevent textarea horizontal resize */
textarea {
    resize: vertical;
}

/* Remove default table spacing */
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* ==========================================================================
   4. Base Tokens — Design System Palette + Primitives
   ========================================================================== */

:root {
  /* Warm darks */
  --color-ink-900: #14100d;
  --color-ink-800: #1c1814;
  --color-ink-700: #25201a;
  --color-ink-600: #322b22;
  --color-ink-500: #423a2e;
  --color-ink-400: #5a4f3f;
  --color-ink-300: #7a6c58;
  --color-ink-200: #a89878;
  --color-ink-100: #d6c9a8;

  /* Parchment / vellum */
  --color-vellum-50:  #f7f1e3;
  --color-vellum-100: #efe6cf;
  --color-vellum-200: #e3d6b6;
  --color-vellum-300: #c9b88f;
  --color-vellum-400: #a8966a;
  --color-vellum-500: #786843;

  /* Ember / oxblood */
  --color-ember-100: #f3c8a3;
  --color-ember-300: #d99366;
  --color-ember-500: #b85a2c;
  --color-ember-600: #9a4520;
  --color-ember-700: #6f2f17;
  --color-ember-800: #4a1f10;

  --color-oxblood-500: #7a1f2b;
  --color-oxblood-600: #5b1620;
  --color-oxblood-700: #3d0e15;

  /* Cool support */
  --color-frost-100: #d6dde2;
  --color-frost-300: #8aa0ab;
  --color-frost-500: #4f6573;
  --color-frost-700: #2a3a45;
  --color-frost-900: #14202a;

  /* Gilt */
  --color-gilt-300: #e8c875;
  --color-gilt-500: #c9a227;
  --color-gilt-700: #8a6f1a;

  /* Status */
  --color-warn:    #c9a227;
  --color-danger:  #b03a2e;
  --color-ok:      #6b8e4e;
  --color-info:    #5b7a8a;

  /* Entry-type palette */
  --color-entry-character:  #d99366;
  --color-entry-species:    #6fa39d;
  --color-entry-culture:    #a07cc8;
  --color-entry-place:      #7da265;
  --color-entry-rune:       #c9a227;
  --color-entry-runemark:   #b8702f;
  --color-entry-mantle:     #b03a4e;
  --color-entry-spell:      #6b89c2;
  --color-entry-faction:    #c43a4e;
  --color-entry-artifact:   #a8814d;
  --color-entry-event:      #8d8478;
  --color-entry-language:   #8aa0ab;
  --color-entry-storyarc:   #8a78c2;
  --color-entry-quest:      #d99366;
  --color-entry-dialogue:   #c9a227;

  /* Type */
  --font-display: "Njord", "Source Serif 4", "Iowan Old Style", "Hoefler Text", Georgia, serif;
  --font-serif:   "Source Serif 4", "Iowan Old Style", "Hoefler Text", Georgia, serif;
  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-runic:   "Noto Sans Runic", "Segoe UI Historic", serif;

  /* Type scale */
  --fs-3xs: 11px;
  --fs-2xs: 12px;
  --fs-xs:  13px;
  --fs-sm:  14px;
  --fs-md:  15px;
  --fs-lg:  17px;
  --fs-xl:  20px;
  --fs-2xl: 24px;
  --fs-3xl: 32px;
  --fs-4xl: 44px;
  --fs-5xl: 60px;
  --fs-6xl: 84px;

  --lh-tight:  1.15;
  --lh-snug:   1.3;
  --lh-normal: 1.55;
  --lh-loose:  1.75;

  --ls-tight:  -0.01em;
  --ls-normal: 0;
  --ls-wide:   0.04em;
  --ls-poster: 0.08em;

  /* Spacing / radii / shadows / motion */
  --space-0:  0;
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;
  --space-9:  96px;
  --space-10: 128px;

  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  --border-hairline: 1px solid rgba(214, 201, 168, 0.10);
  --border-rule:     1px solid rgba(214, 201, 168, 0.18);
  --border-strong:   1px solid rgba(214, 201, 168, 0.30);
  --border-emboss-top:    1px solid rgba(255, 240, 210, 0.05);
  --border-emboss-bottom: 1px solid rgba(0, 0, 0, 0.30);

  --shadow-sm:  0 1px 0 rgba(0,0,0,0.30), 0 1px 2px rgba(0,0,0,0.20);
  --shadow-md:  0 1px 0 rgba(0,0,0,0.30), 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg:  0 2px 0 rgba(0,0,0,0.40), 0 16px 32px rgba(0,0,0,0.45);
  --shadow-glow-ember: 0 0 0 1px rgba(184,90,44,0.25), 0 8px 28px rgba(184,90,44,0.18);

  --easing-settle:   cubic-bezier(0.22, 0.61, 0.36, 1.00);
  --easing-pull:     cubic-bezier(0.55, 0.05, 0.20, 1.00);
  --easing-emerge:   cubic-bezier(0.16, 0.84, 0.32, 1.00);
  --duration-quick:  140ms;
  --duration-normal: 240ms;
  --duration-slow:   420ms;
  --duration-deliberate: 700ms;

  --grain-svg: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.85  0 0 0 0 0.78  0 0 0 0 0.62  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");

  /* Max widths — layout constraints */
  --max-width-content: 1200px;
  --max-width-text:    680px;
  --max-width-narrow:  480px;
}

/* ==========================================================================
   5. Semantic Tokens — Dark (single theme)
   ========================================================================== */

/* --- Dark theme (only mode) --- */
:root {
  --bg-page:        var(--color-ink-800);
  --bg-shell:       var(--color-ink-700);
  --bg-surface:     var(--color-ink-600);
  --bg-surface-2:   var(--color-ink-500);
  --bg-overlay:     rgba(20, 16, 13, 0.74);

  --fg-1:           var(--color-ink-100);
  --fg-2:           var(--color-ink-200);
  --fg-3:           var(--color-ink-300);
  --fg-on-accent:   #f7f1e3;
  --fg-link:        var(--color-ember-300);
  --fg-link-hover:  var(--color-ember-100);

  --accent:         var(--color-ember-500);
  --accent-strong:  var(--color-ember-600);
  --accent-soft:    rgba(184, 90, 44, 0.16);
  --accent-frost:   var(--color-frost-500);
  --accent-gilt:    var(--color-gilt-500);

  --border:         rgba(214, 201, 168, 0.14);
  --border-strong-c: rgba(214, 201, 168, 0.28);

  --selection-bg:   rgba(184, 90, 44, 0.40);
  --selection-fg:   #f7f1e3;
}

/* ==========================================================================
   6. Element Baselines — body, headings, type classes, links
   ========================================================================== */

/* Selection highlight */
::selection {
    background: var(--selection-bg);
    color: var(--selection-fg);
}

/* Body defaults */
body, .ms-body {
    background: var(--bg-page);
    color: var(--fg-1);
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Headings */
h1, .ms-h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(var(--fs-3xl), 4.4vw, var(--fs-5xl));
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
    color: var(--fg-1);
    margin: 0;
}

h2, .ms-h2 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: var(--fs-3xl);
    line-height: var(--lh-snug);
    letter-spacing: var(--ls-tight);
    color: var(--fg-1);
    margin: 0;
}

h3, .ms-h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-2xl);
    line-height: var(--lh-snug);
    color: var(--fg-1);
    margin: 0;
}

h4, .ms-h4 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-xl);
    line-height: var(--lh-snug);
    color: var(--fg-1);
    margin: 0;
}

/* Eyebrow — small caps label above headings */
.ms-eyebrow {
    font-family: var(--font-sans);
    font-size: var(--fs-2xs);
    font-weight: 600;
    letter-spacing: var(--ls-poster);
    text-transform: uppercase;
    color: var(--fg-3);
}

/* Caption — small muted text */
.ms-caption {
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    color: var(--fg-3);
}

/* Body long — longform readable text */
.ms-body-long {
    font-family: var(--font-serif);
    font-size: var(--fs-lg);
    line-height: var(--lh-loose);
    color: var(--fg-1);
    text-wrap: pretty;
}

/* Label — form / UI labels */
.ms-label {
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--fg-2);
}

/* Monospace — code, IDs, rune context */
.ms-mono, code, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
    background: rgba(214, 201, 168, 0.07);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
}

pre {
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
}

/* Links */
a {
    color: var(--fg-link);
    text-decoration: underline;
    text-decoration-thickness: 0.5px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--fg-link-hover);
}

/* ==========================================================================
   7. Design System Utility Classes — surfaces, grain, rule
   ========================================================================== */

/* Surface — every "card" in the system reads through these */
.ms-surface {
    background: var(--bg-surface);
    border: var(--border-rule);
    border-radius: var(--radius-md);
    position: relative;
}

/* Grain overlay on surfaces */
.ms-surface::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--grain-svg);
    background-size: 220px 220px;
    pointer-events: none;
    opacity: 0.55;
    border-radius: inherit;
    mix-blend-mode: overlay;
}

/* Texture utility — apply to large hero plates */
.ms-grain {
    position: relative;
}

.ms-grain::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--grain-svg);
    background-size: 220px 220px;
    pointer-events: none;
    opacity: 0.45;
    mix-blend-mode: overlay;
}

/* Hairline rule — scribed divider */
.ms-rule {
    height: 1px;
    background: linear-gradient(to right,
        transparent 0%,
        var(--border-strong-c) 18%,
        var(--border-strong-c) 82%,
        transparent 100%);
    border: 0;
}

/* ==========================================================================
   8. Site Utilities — container, visually-hidden, skip-link, scroll reveal
   ========================================================================== */

/* --- Container --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

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

/* --- Skip-to-main link --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-3);
    background-color: var(--accent);
    color: var(--fg-on-accent);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    z-index: 300;
    transition: top var(--duration-quick) var(--easing-settle);
}

.skip-link:focus {
    top: var(--space-3);
}

/* --- Scroll reveal animation --- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition:
        opacity var(--duration-slow) var(--easing-settle),
        transform var(--duration-slow) var(--easing-settle);
}

.reveal--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Respect reduced motion preference for reveal */
@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ==========================================================================
   9. Smooth Scroll — respecting reduced motion preference
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Disable animations and transitions for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   10. Shared Layout Utilities
   Used across multiple pages to replace common inline styles.
   ========================================================================== */

/* Footer layout — shared flex row for studio, ashborn, and mimir footers */
.footer-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
}

/* Social icon row — inline flex with gap */
.social-icons {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Footer nav links — pushed to the right */
.footer-nav {
    margin-left: auto;
}

@media (max-width: 767px) {
    .footer-nav {
        margin-left: 0;
    }
}

/* Centered section head modifier */
.text-center {
    text-align: center;
}

/* Auto-center inline margin utility */
.margin-inline-auto {
    margin-inline: auto;
}

/* 404 page — full viewport centered section */
.error-page {
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--color-ink-900);
}

/* 404 heading — large display number */
.error-page__code {
    font-family: var(--font-display);
    font-size: clamp(64px, 10vw, 120px);
    color: var(--fg-1);
    margin: 0;
}

/* 404 message text */
.error-page__message {
    font-family: var(--font-serif);
    font-size: 19px;
    color: var(--fg-2);
    margin: 12px 0 24px;
}

/* 404 return link */
.error-page__link {
    color: var(--fg-link);
    display: inline-block;
}
