/* ==========================================================================
   Arhipelagul stuficol — Public Microsite Stylesheet
   Dual Theming (Dark/Light), WCAG AAA Contrast, Fluid Typography
   ========================================================================== */

:root {
  /* Color Palette - Dark Mode (Default) */
  --bg-page: #0d1210;
  --bg-surface: #141b18;
  --bg-surface-elevated: #1b2420;
  --bg-surface-inset: #090c0b;
  
  --border-subtle: #27342e;
  --border-strong: #3d5047;
  --border-accent: #e0a64e;

  /* Typography Colors (Checked for WCAG AAA >= 7:1 on dark bg) */
  --text-primary: #edf3ef;       /* contrast ~15.2:1 */
  --text-secondary: #b2c4ba;     /* contrast ~8.1:1 */
  --text-muted: #889e92;         /* contrast ~4.9:1 (large text / metadata) */
  
  /* Semantic Accent Tones */
  --accent-reed: #e5a952;        /* amber dried reed */
  --accent-reed-bg: rgba(229, 169, 82, 0.12);
  --accent-rust: #d9633e;        /* oxidized iron / boiler rust */
  --accent-rust-bg: rgba(217, 99, 62, 0.12);
  --accent-ice: #7dcad3;         /* frozen river / frost */
  --accent-ice-bg: rgba(125, 202, 211, 0.12);
  --accent-danger: #e64a38;
  --accent-danger-bg: rgba(230, 74, 56, 0.15);

  /* Fonts */
  --font-serif: "Charter", "Bitstream Charter", "Iowan Old Style", "Georgia", "Cambria", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", monospace;

  --max-width-text: 68ch;
  --max-width-wide: 1040px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

[data-theme="light"] {
  /* Color Palette - Light Mode */
  --bg-page: #f6f8f6;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #edf2ee;
  --bg-surface-inset: #e2e8e4;

  --border-subtle: #d0ded6;
  --border-strong: #96aa9f;
  --border-accent: #945d0b;

  /* Typography Colors (Checked for WCAG AAA >= 7:1 on light bg) */
  --text-primary: #121c17;       /* contrast ~16.5:1 */
  --text-secondary: #2c3f35;     /* contrast ~9.4:1 */
  --text-muted: #4e6558;         /* contrast ~5.2:1 */

  /* Semantic Accent Tones (darkened for high contrast on light bg) */
  --accent-reed: #945d0b;        /* deep bronze-amber */
  --accent-reed-bg: rgba(148, 93, 11, 0.08);
  --accent-rust: #9e3618;        /* deep rust iron */
  --accent-rust-bg: rgba(158, 54, 24, 0.08);
  --accent-ice: #0a5d6a;         /* deep river teal */
  --accent-ice-bg: rgba(10, 93, 106, 0.08);
  --accent-danger: #b31d0e;
  --accent-danger-bg: rgba(179, 29, 14, 0.1);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.75;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--accent-reed);
  color: #000;
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-weight: bold;
  z-index: 1000;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus {
  top: 1rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-page);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-brand:hover, .site-brand:focus {
  color: var(--text-primary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-switch, .theme-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  min-height: 44px; /* Touch target minimum */
  min-width: 44px;
  justify-content: center;
}

.lang-switch:hover, .theme-toggle:hover,
.lang-switch:focus, .theme-toggle:focus {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

/* ==========================================================================
   Typography & Flow Elements
   ========================================================================== */

main {
  flex: 1;
}

.article-header {
  padding: 4.5rem 1.25rem 2.5rem;
  max-width: var(--max-width-text);
  margin: 0 auto;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-reed);
  margin-bottom: 1rem;
}

h1.article-title {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.article-deck {
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-style: italic;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.meta-pill {
  background: var(--bg-surface-elevated);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Story Chapters & Body Copy */
.prose {
  max-width: var(--max-width-text);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.prose p {
  margin-bottom: 1.6rem;
  color: var(--text-primary);
}

.prose h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-top: 3.5rem;
  margin-bottom: 1.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.prose h3 {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
}

.prose blockquote {
  border-left: 3px solid var(--accent-reed);
  padding: 0.85rem 0 0.85rem 1.4rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.prose blockquote cite {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

.prose strong {
  font-weight: 700;
  color: var(--text-primary);
}

.prose em {
  font-style: italic;
}

.prose hr {
  border: 0;
  height: 1px;
  background: var(--border-subtle);
  margin: 3.5rem auto;
  max-width: 60%;
}

/* ==========================================================================
   Discovery Cards (The Three Findings)
   ========================================================================== */

.findings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2.5rem 0 3.5rem;
}

.finding-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
}

.finding-card.silica { border-top: 4px solid var(--accent-rust); }
.finding-card.barge { border-top: 4px solid var(--accent-ice); }
.finding-card.maliuc { border-top: 4px solid var(--accent-reed); }

.finding-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.finding-card.silica .finding-num { color: var(--accent-rust); }
.finding-card.barge .finding-num { color: var(--accent-ice); }
.finding-card.maliuc .finding-num { color: var(--accent-reed); }

.finding-card h3 {
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.75rem;
  margin-top: 0;
}

.finding-card p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ==========================================================================
   Full Width Visuals & Semantic Figures
   ========================================================================== */

.media-container {
  max-width: var(--max-width-wide);
  margin: 2.5rem auto;
  padding: 0 1.25rem;
}

figure.doc-figure {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 2.5rem 0;
}

.figure-graphic {
  padding: 1.5rem;
  background: var(--bg-surface-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

figcaption {
  padding: 1rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

figcaption strong {
  color: var(--text-primary);
}

.attribution {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-family: var(--font-mono);
}

/* ==========================================================================
   Interactive Module 1: Silica Vitrification & Boiler Simulator
   ========================================================================== */

.interactive-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin: 3rem 0;
}

.interactive-header {
  margin-bottom: 1.5rem;
}

.interactive-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-reed);
  display: inline-block;
  margin-bottom: 0.4rem;
}

.interactive-header h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

.interactive-header p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Species Switch Tabs */
.species-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.toggle-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

.toggle-btn:hover, .toggle-btn:focus {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--accent-reed-bg);
  border-color: var(--accent-reed);
  color: var(--accent-reed);
}

/* Chemical Comparison Bars */
.chem-bars {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.chem-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.chem-label-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.chem-track {
  height: 14px;
  background: var(--bg-surface-inset);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.chem-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.chem-fill.ash { background: #b08d51; }
.chem-fill.silica { background: var(--accent-rust); }
.chem-fill.fiber { background: var(--accent-ice); }

/* Boiler Temperature Slider */
.slider-container {
  background: var(--bg-surface-elevated);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.slider-title {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.slider-val {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-rust);
}

input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-surface-inset);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-rust);
  border: 2px solid var(--text-primary);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-rust);
  border: 2px solid var(--text-primary);
  cursor: pointer;
}

.reaction-feedback {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-inset);
  border-left: 4px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.reaction-feedback.critical {
  border-left-color: var(--accent-danger);
  background: var(--accent-danger-bg);
  color: var(--text-primary);
}

/* ==========================================================================
   Interactive Module 2: Penal Geography & Map Atlas
   ========================================================================== */

.atlas-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (min-width: 860px) {
  .atlas-container {
    grid-template-columns: 1.4fr 1fr;
  }
}

.atlas-map-wrap {
  background: var(--bg-surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.atlas-dossier {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.dossier-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-ice);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.dossier-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.dossier-coord {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.dossier-quote {
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text-secondary);
  border-left: 2px solid var(--accent-ice);
  padding-left: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

.dossier-facts {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.map-node {
  transition: transform 0.15s ease;
}
.map-node:hover, .map-node:focus {
  transform: scale(1.15);
}
.map-node.active circle:nth-child(2),
.map-node.active polygon {
  stroke: #fffae0;
  stroke-width: 3;
}

/* ==========================================================================
   Interactive Module 3: Ground Pressure Calculator
   ========================================================================== */

.pressure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.pressure-calc-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.pressure-result-box {
  background: var(--bg-surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.pressure-value {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
  color: var(--accent-reed);
  margin-bottom: 0.35rem;
}

.pressure-unit {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.plaur-verdict {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  width: 100%;
}

.plaur-verdict.safe {
  background: var(--accent-reed-bg);
  color: var(--accent-reed);
  border: 1px solid var(--accent-reed);
}

.plaur-verdict.danger {
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
  border: 1px solid var(--accent-danger);
}

/* ==========================================================================
   Dossier: Atestat / Legendă / Interpretare
   ========================================================================== */

.method-matrix {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 2.5rem 0;
}

@media (min-width: 760px) {
  .method-matrix {
    grid-template-columns: repeat(3, 1fr);
  }
}

.matrix-col {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.matrix-col.attested { border-top: 4px solid var(--accent-ice); }
.matrix-col.myth { border-top: 4px solid var(--accent-rust); }
.matrix-col.interpretation { border-top: 4px solid var(--accent-reed); }

.matrix-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

.matrix-col.attested .matrix-badge { color: var(--accent-ice); }
.matrix-col.myth .matrix-badge { color: var(--accent-rust); }
.matrix-col.interpretation .matrix-badge { color: var(--accent-reed); }

.matrix-col h4 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  margin-top: 0;
}

.matrix-col p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.matrix-col ul {
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.matrix-col li {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: 0.5rem;
}

.matrix-col li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 4rem 1.25rem 3rem;
  margin-top: 5rem;
}

.footer-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
  align-items: flex-start;
}

.footer-brand h4 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.footer-brand p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 45ch;
  line-height: 1.5;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-links a:hover, .footer-links a:focus {
  color: var(--accent-reed);
  text-decoration: underline;
}

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Accessibility & Responsive QA Tuning
   ========================================================================== */

@media (max-width: 480px) {
  body {
    font-size: 1.0625rem;
  }
  .article-header {
    padding-top: 2.5rem;
  }
  .interactive-box {
    padding: 1.25rem 1rem;
  }
  .pressure-value {
    font-size: 2.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
