/* =============================================================
   Fenja AI — Nordic Editorial Design System
   "The Digital Archivist"
   ============================================================= */

/* ----------  Fonts  ------------------------------------------ */
@font-face {
  font-family: "Manrope";
  font-weight: 200;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-ExtraLight.ttf") format("truetype");
}
@font-face {
  font-family: "Manrope";
  font-weight: 300;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-Light.ttf") format("truetype");
}
@font-face {
  font-family: "Manrope";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Manrope";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-Medium.ttf") format("truetype");
}
@font-face {
  font-family: "Manrope";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-SemiBold.ttf") format("truetype");
}
@font-face {
  font-family: "Manrope";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-Bold.ttf") format("truetype");
}
@font-face {
  font-family: "Manrope";
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Manrope-ExtraBold.ttf") format("truetype");
}

@font-face {
  font-family: "Newsreader";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Newsreader-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Newsreader";
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  src: url("./fonts/Newsreader-Italic.ttf") format("truetype");
}
@font-face {
  font-family: "Newsreader";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Newsreader-Bold.ttf") format("truetype");
}
@font-face {
  font-family: "Newsreader";
  font-weight: 700;
  font-style: italic;
  font-display: swap;
  src: url("./fonts/Newsreader-BoldItalic.ttf") format("truetype");
}
@font-face {
  font-family: "Newsreader";
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Newsreader-ExtraBold.ttf") format("truetype");
}

/* ----------  Tokens  ----------------------------------------- */
:root {
  /* --- Core neutrals (unbleached paper, clay, slate) --- */
  --background:                    #faf6ee;  /* base canvas — warm paper */
  --surface:                       #faf6ee;
  --surface-container-lowest:      #fffcf7;  /* most-elevated — unbleached paper, never pure white */
  --surface-container-low:         #f6f2e8;
  --surface-container:             #efeadc;
  --surface-container-high:        #e7e1d0;
  --surface-container-highest:     #ddd6c3;
  --surface-variant:               #ddd6c3;

  --on-surface:                    #383831;  /* charcoal slate */
  --on-surface-variant:            #5f5e5e;
  --on-surface-muted:              #8a887f;

  --primary:                       #5f5e5e;
  --on-primary:                    #fffcf7;

  --secondary:                     #785f53;  /* hand-rubbed wood */
  --secondary-dim:                 #6b5348;
  --on-secondary:                  #ffffff;
  --secondary-fixed-dim:           #9a8679;

  --outline:                       #babab0;
  --outline-variant:               #babab0;  /* used at 15% for ghost borders */

  /* --- Archival Pigment accent palette (flat, matte inks) --- */
  --pigment-terracotta:            #b96b58;  /* warnings, critical */
  --pigment-copper:                #6d8c7c;  /* success, growth */
  --pigment-ochre:                 #c29d59;  /* cautions, tertiary */
  --pigment-indigo:                #5a6d83;  /* info, neutral data */
  --pigment-heather:               #8d7a85;  /* categorical, supportive */

  /* --- Semantic state mappings --- */
  --color-success:                 var(--pigment-copper);
  --color-warning:                 var(--pigment-ochre);
  --color-danger:                  var(--pigment-terracotta);
  --color-info:                    var(--pigment-indigo);

  /* --- Type families --- */
  --font-serif:  "Newsreader", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-sans:   "Manrope", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* --- Type scale (clamped for responsive) --- */
  --text-display-xl:  clamp(3.5rem, 6vw, 5.5rem);   /* 56–88 */
  --text-display-lg:  clamp(3rem, 5vw, 4.5rem);     /* 48–72 */
  --text-display-md:  clamp(2.5rem, 4vw, 3.5rem);   /* 40–56 */
  --text-headline-lg: 2.25rem;   /* 36 */
  --text-headline-md: 1.75rem;   /* 28 */
  --text-headline-sm: 1.375rem;  /* 22 */
  --text-title-lg:    1.125rem;  /* 18 */
  --text-title-md:    1rem;      /* 16 */
  --text-body-lg:     1.0625rem; /* 17 */
  --text-body-md:     1rem;      /* 16 */
  --text-body-sm:     0.875rem;  /* 14 */
  --text-label-md:    0.8125rem; /* 13 */
  --text-label-sm:    0.75rem;   /* 12 */

  /* Letter-spacing */
  --tracking-tight:   -0.02em;
  --tracking-snug:    -0.01em;
  --tracking-normal:  0;
  --tracking-wide:    0.04em;
  --tracking-wider:   0.08em;

  /* Line-heights */
  --leading-tight:    1.1;
  --leading-snug:     1.25;
  --leading-normal:   1.5;
  --leading-relaxed:  1.6;
  --leading-loose:    1.75;

  /* --- Spacing scale (editorial, generous) --- */
  --space-1:   0.25rem;   /* 4   */
  --space-2:   0.5rem;    /* 8   */
  --space-3:   0.75rem;   /* 12  */
  --space-4:   1rem;      /* 16  */
  --space-5:   1.5rem;    /* 24  */
  --space-6:   2rem;      /* 32  — list separator default */
  --space-7:   2.5rem;    /* 40  */
  --space-8:   2.75rem;   /* 44  — hero-card padding */
  --space-10:  4rem;      /* 64  */
  --space-12:  5rem;      /* 80  */
  --space-16:  6rem;      /* 96  */
  --space-20:  7rem;      /* 112 — desktop lateral margin */
  --space-24:  8rem;      /* 128 */

  /* --- Radii --- */
  --radius-none: 0;
  --radius-sm:   0.375rem;  /* 6  */
  --radius-md:   0.75rem;   /* 12 — primary */
  --radius-lg:   1.25rem;   /* 20 */
  --radius-full: 9999px;

  /* --- Elevation (atmospheric, warm) --- */
  --shadow-none:    none;
  --shadow-ambient: 0 12px 32px -12px rgba(56, 56, 49, 0.06);
  --shadow-float:   0 24px 48px -16px rgba(56, 56, 49, 0.05), 0 4px 12px -4px rgba(56, 56, 49, 0.04);
  --shadow-modal:   0 40px 64px -24px rgba(56, 56, 49, 0.08), 0 8px 16px -6px rgba(56, 56, 49, 0.04);

  /* --- Ghost border (WCAG fallback only) --- */
  --ghost-border-color: rgba(186, 186, 176, 0.15);
  --ghost-border:       1px solid var(--ghost-border-color);

  /* --- Glass --- */
  --glass-blur:    blur(16px);
  --glass-surface: rgba(255, 252, 247, 0.8);

  /* --- Motion --- */
  --ease-standard: cubic-bezier(0.2, 0.0, 0, 1);
  --ease-entrance: cubic-bezier(0, 0, 0, 1);
  --ease-exit:     cubic-bezier(0.3, 0, 1, 1);
  --duration-fast: 140ms;
  --duration-med:  240ms;
  --duration-slow: 420ms;

  /* --- Layout --- */
  --content-max:  72rem;    /* 1152 */
  --reading-max:  42rem;    /* 672  */
}

/* ----------  Base semantic styles  --------------------------- */
html {
  font-family: var(--font-sans);
  color: var(--on-surface);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-size: var(--text-body-md);
  line-height: var(--leading-relaxed);
  color: var(--on-surface);
  background: var(--background);
}

/* Display — serif, tight, left-aligned editorial intent */
.display-xl,
.display-lg,
.display-md {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--on-surface);
  margin: 0 0 var(--space-5) 0;
}
.display-xl { font-size: var(--text-display-xl); }
.display-lg { font-size: var(--text-display-lg); }
.display-md { font-size: var(--text-display-md); }

/* Headlines — serif, authoritative */
h1, .headline-lg,
h2, .headline-md,
h3, .headline-sm {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--on-surface);
  letter-spacing: var(--tracking-snug);
  line-height: var(--leading-snug);
  margin: 0 0 var(--space-4) 0;
}
h1, .headline-lg { font-size: var(--text-headline-lg); }
h2, .headline-md { font-size: var(--text-headline-md); }
h3, .headline-sm { font-size: var(--text-headline-sm); }

/* Titles — sans, precise structural labels */
h4, .title-lg,
h5, .title-md {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: var(--tracking-normal);
  line-height: var(--leading-snug);
  margin: 0 0 var(--space-3) 0;
}
h4, .title-lg { font-size: var(--text-title-lg); }
h5, .title-md { font-size: var(--text-title-md); }

/* Body */
p, .body-md {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--text-body-md);
  line-height: var(--leading-relaxed);
  color: var(--on-surface);
  margin: 0 0 var(--space-4) 0;
  text-wrap: pretty;
}
.body-lg {
  font-size: var(--text-body-lg);
  line-height: var(--leading-relaxed);
}
.body-sm {
  font-size: var(--text-body-sm);
  line-height: var(--leading-normal);
  color: var(--on-surface-variant);
}

/* Labels — muted, small caps optional */
.label-md,
.label-sm {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--on-surface-variant);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}
.label-md { font-size: var(--text-label-md); }
.label-sm { font-size: var(--text-label-sm); }

/* Editorial lead — serif italic, subtle */
.lead {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-body-lg);
  color: var(--on-surface-variant);
  line-height: var(--leading-relaxed);
}

/* Inline code / mono */
code, kbd, samp, pre, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--on-surface);
}

/* Links — editorial, no underline until hover */
a {
  color: var(--secondary);
  text-decoration: none;
  border-bottom: 1px solid rgba(120, 95, 83, 0.3);
  transition: border-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
a:hover {
  color: var(--secondary-dim);
  border-bottom-color: currentColor;
}

/* Selection — warm, not blue */
::selection {
  background: rgba(120, 95, 83, 0.18);
  color: var(--on-surface);
}

/* Utility: ghost border fallback */
.ghost-border { border: var(--ghost-border); }
.ghost-border-bottom { border-bottom: var(--ghost-border); }
