@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=Inter+Tight:wght@300;400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;1,6..72,400;1,6..72,500&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design tokens — Direction B: Kalevala / scholarly ─── */
:root {
  --bg:      #ece5d4;
  --surface: #f6f0df;
  --ink:     #1a1f2b;
  --ink-2:   #3d4654;
  --ink-3:   #80796a;
  --rule:    #c8bea1;
  --primary: #1f3a52;
  --primary-2: #355374;
  --accent:  #bd6d59;
  --warm:    #a78250;
  --swan:  #eeeeee;
  --logotext: #f6f0df;
  --grey: #999999;

  --sans:  'Inter Tight', system-ui, -apple-system, sans-serif;
  --serif: 'Newsreader', 'Cormorant Garamond', Georgia, serif;
  --mono:  'JetBrains Mono', ui-monospace, monospace;

  --max: 780px;
  --pad: clamp(1.25rem, 5vw, 3rem);
  --r:   10px;
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  background-image: radial-gradient(rgba(0,0,0,.018) 1px, transparent 1px);
  background-size: 3px 3px;
}

/* ─── Container ─────────────────────────────────────── */
.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
 
  background-repeat: repeat;
  background-size: 180px 120px;
}

/* ─── Folk border ───────────────────────────────────── */
.folk-bar {
  color: var(--primary);
  background: var(--surface);
  overflow: hidden;
  line-height: 0;
}

/* ─── Rule ──────────────────────────────────────────── */
.kj-rule {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--primary), transparent);
  opacity: .45;
  max-width: var(--max);
  margin: 2.5rem auto;
  padding: 0 var(--pad);
}

/* ═══════════════════════════════════════════════════
   INDEX PAGE
   ═══════════════════════════════════════════════════ */

/* ─── Site header ───────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0;
  background-image: url('forest-pattern.svg');
  position: relative;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: none;
}

/* ─── Logo ──────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.logo-swan { color: var(--swan); flex-shrink: 0; }
.logo-name {
  display: block;
  font-family: var(--serif);
  font-style: normal;
  font-weight: 500;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  letter-spacing: -0.015em;
  line-height: 1.02;
  color: var(--logotext);
}
.logo-sub {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 9px;
  font-weight: 500;
  color: var(--rule);
  padding-top: 5px;
}
/* Initial letter — K and J */
.logo-initial {
  font-style: italic;
  color: var(--accent);
  font-size: 1.22em;
  line-height: 1;
  letter-spacing: 0;
}

/* Compact in sticky text-page header */
.text-page-header .logo-name {
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* ─── Header nav ────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-shrink: 0;
  color: var(--rule);
  
}
.site-nav-item {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--rule);
  text-decoration: none;
  transition: color 0.12s;
  white-space: nowrap;
  padding-top: 1.5rem;
}
.site-nav-item:hover { color: var(--warm); }
.site-nav-item--active { color: var(--warm); }

/* ─── Burger menu button ────────────────────────────── */
.nav-burger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.burger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--logotext);
  border-radius: 2px;
  transition: transform 0.22s, opacity 0.22s;
  transform-origin: center;
}
.nav-burger.is-open .burger-bar:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}
.nav-burger.is-open .burger-bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav-burger.is-open .burger-bar:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

/* ─── Page intro ────────────────────────────────────── */
.page-intro {
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--rule);
  
}
.kj-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  margin-bottom: 1.25rem;
}
.page-intro h1 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4.2vw, 3.125rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 0.875rem;
}
.page-intro-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.0625rem;
  color: var(--ink-3);
}

/* ─── Level sections ────────────────────────────────── */
.level-section {
  padding: 3.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.level-section:last-of-type { border-bottom: none; }

.level-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}
.level-icon-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  margin-top: 2px;
}

/* ─── Level badges ──────────────────────────────────── */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.badge-sm { width: 2.25rem; height: 2.25rem; font-size: 0.6875rem; }

.lvl-a1 { background: #d0dce8; color: #1f3a52; }
.lvl-a2 { background: #b5c6d6; color: #152d44; }
.lvl-b1 { background: #e8d4a8; color: #5c3a10; }
.lvl-b2 { background: #d8c098; color: #4a2808; }

.level-meta { flex: 1; }
.level-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  margin-bottom: 0.5rem;
}
.level-name {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
.level-name-en {
  font-size: 1rem;
  font-weight: 300;
  color: var(--ink-3);
  font-family: var(--sans);
  font-style: normal;
  letter-spacing: 0;
}
.level-desc {
  font-size: 0.8125rem;
  color: var(--ink-3);
  margin-top: 0.25rem;
  font-style: italic;
  font-family: var(--serif);
}

/* ─── Lukutekstit 2-column layout ──────────────────── */
.levels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
}
.levels-grid #level-a1 { grid-column: 1; grid-row: 1; }
.levels-grid #level-a2 { grid-column: 2; grid-row: 1; }
.levels-grid #level-b1 { grid-column: 1; grid-row: 2; }
.levels-grid #level-b2 { grid-column: 2; grid-row: 2; }
.levels-grid .level-section { border-bottom: none; }
@media (max-width: 600px) {
  .levels-grid { display: block; }
}

/* ─── Text list ─────────────────────────────────────── */
.text-list {
  list-style: none;
  border-top: 1px solid var(--rule);
}
.text-list li { border-bottom: 1px solid var(--rule); }


.text-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9375rem 0.25rem 0.9375rem 0;
  text-decoration: none;
  color: var(--ink);
  transition: color 0.12s;
}
.text-link:hover { color: var(--primary); }

.text-icon {
  flex-shrink: 0;
  color: var(--ink-3);
  transition: color 0.12s;
  opacity: 0.6;
}
.text-link:hover .text-icon { color: var(--accent); opacity: 1; }

.text-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  min-width: 1.75rem;
  flex-shrink: 0;
  transition: color 0.12s;
}
.text-link:hover .text-num { color: var(--primary); }

.text-titles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.text-fi-link {
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.3;
}
.text-en-link {
  font-size: 0.8125rem;
  color: var(--ink-3);
  font-weight: 300;
}
.text-arrow {
  color: var(--ink-3);
  font-size: 0.8125rem;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.12s, transform 0.12s;
}
.text-link:hover .text-arrow { opacity: 1; transform: translateX(0); }

/* ─── Footer skyline ────────────────────────────────── */
.footer-skyline {
  width: 100%;
  line-height: 0;
  overflow: hidden;
}
.footer-skyline img {
  display: block;
  width: 100%;
  height: auto;
}

/* ─── Home grid ─────────────────────────────────────── */
.home-grid-wrap {
  padding: 3rem var(--pad);
  max-width: var(--max);
  margin: 0 auto;
}
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.home-block {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 3.5rem 2rem;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.home-block:hover {
  background: var(--primary);
  color: #f0e8d0;
  border-color: var(--primary);
}
@media (max-width: 480px) {
  .home-grid { grid-template-columns: 1fr; }
}

/* ─── Footer ────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding: 0;
}
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
.footer-copy {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.8125rem;
  color: var(--ink-3);
}
.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}
.footer-links a {
  font-size: 0.8125rem;
  color: var(--ink-3);
  text-decoration: none;
  transition: color 0.12s;
}
.footer-links a:hover { color: var(--ink); }

/* ═══════════════════════════════════════════════════
   TEXT PAGES
   ═══════════════════════════════════════════════════ */

/* ─── Page header (sticky) ──────────────────────────── */
.text-page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.text-page-header .folk-bar { line-height: 0; }
.text-page-header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.12s;
}
.back-link:hover { color: var(--primary); }

/* ─── Text hero ─────────────────────────────────────── */
.text-article { padding-bottom: 4rem; }

.text-hero {
  background: var(--bg);
  background-repeat: repeat;
  background-size: 180px 120px;
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--rule);
}
.text-number {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.text-fi-h1 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4.2vw, 3.125rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 0.875rem;
}
.text-en-h2 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--ink-3);
}

/* ─── Finnish text body ─────────────────────────────── */
.text-body { padding: 2.75rem 0 1rem; }
.text-body p {
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.75;
  color: var(--ink);
  margin-bottom: 1.35em;
}
.text-body p:last-child { margin-bottom: 0; }

/* ─── Collapsible panels ────────────────────────────── */
.panel {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  margin: 1.5rem 0;
  overflow: hidden;
  background: var(--surface);
}
.panel > summary {
  padding: 0.9375rem 1.25rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--ink-2);
  user-select: none;
  transition: background 0.12s;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before {
  content: '▸';
  font-size: 0.625rem;
  color: var(--ink-3);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.panel[open] > summary::before { transform: rotate(90deg); }
.panel > summary:hover { background: #ede7d4; color: var(--ink); }
.panel[open] > summary { border-bottom: 1px solid var(--rule); }

.panel-body { padding: 1.5rem 1.375rem; }
.panel-body p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-2);
  margin-bottom: 1.1em;
}
.panel-body p:last-child { margin-bottom: 0; }
.panel-body ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.panel-body li {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--ink-2);
  margin-bottom: 0.4em;
}
.panel-body code {
  font-family: var(--mono);
  font-size: 0.8125em;
  background: rgba(31,58,82,.08);
  padding: 0.125em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}
.panel-grammar > summary { color: var(--accent); }
.panel-grammar > summary::before { color: var(--accent); opacity: .6; }

/* ─── Word hover tooltip ────────────────────────────── */
.fi-word {
  cursor: help;
  border-radius: 2px;
  transition: background 0.08s, color 0.08s;
}
.fi-word:hover {
  background: rgba(31, 58, 82, 0.09);
  color: var(--primary);
}
.word-tooltip {
  position: fixed;
  z-index: 300;
  background: var(--primary);
  color: #f0e8d0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9375rem;
  line-height: 1.45;
  padding: 0.5rem 0.875rem;
  border-radius: 4px;
  max-width: 340px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.12s, transform 0.12s;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
}
.word-tooltip.tip-on {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Text navigation ───────────────────────────────── */
.text-nav {
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding: 1.125rem 0;
}
.text-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-link:hover { background: var(--rule); color: var(--ink); }
.nav-home { color: var(--ink-3); flex-shrink: 0; }
.nav-disabled { color: var(--ink-3); opacity: 0.35; pointer-events: none; }

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
  .text-hero { padding: 2.5rem 0 2rem; }
  .level-section { padding: 2.75rem 0; }
  .text-body p { font-size: 1.0625rem; }
  .logo-name { font-size: 1.125rem; }
  .page-intro h1 { letter-spacing: -0.02em; }
  .footer-links { gap: 1rem; flex-wrap: wrap; }

  /* ── Burger menu ── */
  .nav-burger { display: flex; }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  }
  .site-nav.nav-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .site-nav-item {
    padding: 0.875rem var(--pad);
    font-size: 1.0625rem;
    border-bottom: 1px solid var(--rule);
    white-space: normal;
  }
  .site-nav-item:last-child { border-bottom: none; }
}
