:root {
  --paper: #f2e9d8;
  --paper-2: #ebe0cb;
  --paper-3: #e3d6bd;
  --ink: #1e2a4a;
  --wine: #7b2d3a;
  --gold: #c5a24e;
  --fg: #241f1a;
  --muted: #6b5f4f;
  --line: rgba(30, 42, 74, 0.16);
  --line-soft: rgba(30, 42, 74, 0.1);
  --maxw: 1160px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: "Lora", "PT Serif", Georgia, serif;
  --body: "Noto Serif", "PT Serif", Georgia, serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--fg);
  font-family: var(--body);
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* Subtle paper grain via layered fractal-noise SVG (fixed, behind everything) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

img, svg, canvas { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.005em;
  color: var(--ink);
}
h2 { font-size: clamp(1.9rem, 4vw, 3rem); }
h3 { font-size: 1.35rem; }

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--wine); color: var(--paper); padding: 10px 16px; border-radius: 8px;
  transition: top 0.2s; font-family: var(--serif);
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--wine); outline-offset: 3px; border-radius: 3px; }

.eyebrow {
  font-family: var(--serif);
  font-size: 0.8rem;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--wine);
  margin-bottom: 1rem;
}
.accent { color: var(--wine); font-style: italic; }

.section-head { max-width: 720px; margin: 0 auto clamp(2.5rem, 6vw, 4rem); text-align: center; }
.section-sub { color: var(--muted); font-size: 1.05rem; margin-top: 1rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0.85rem 1.7rem; border-radius: 4px; font-family: var(--serif);
  font-weight: 500; font-size: 1rem; letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s, color 0.3s;
  will-change: transform; cursor: pointer;
}
.btn--sm { min-height: 40px; padding: 0.6rem 1.1rem; font-size: 0.92rem; }
.btn--solid { background: var(--ink); color: var(--paper); box-shadow: 0 6px 18px rgba(30, 42, 74, 0.18); }
.btn--solid:hover { transform: translateY(-2px); background: #16203b; box-shadow: 0 12px 32px rgba(30, 42, 74, 0.28); }
.btn--ghost { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn--ghost:hover { transform: translateY(-2px); background: rgba(30, 42, 74, 0.06); }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem clamp(1.1rem, 4vw, 2.5rem);
  backdrop-filter: blur(8px);
  background: linear-gradient(to bottom, rgba(242, 233, 216, 0.92), rgba(242, 233, 216, 0.55) 70%, rgba(242, 233, 216, 0));
  border-bottom: 1px solid transparent;
}
.nav__brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--serif); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.14em; color: var(--ink); }
.nav__mark {
  width: 18px; height: 22px; border-radius: 2px; position: relative; flex: none;
  border: 1.5px solid var(--ink);
  background: linear-gradient(to right, transparent calc(50% - 0.75px), var(--ink) calc(50% - 0.75px), var(--ink) calc(50% + 0.75px), transparent calc(50% + 0.75px));
}
.nav__mark::after { content: ""; position: absolute; top: -4px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--gold); }
.nav__links { display: flex; align-items: center; gap: clamp(0.8rem, 2vw, 1.7rem); }
.nav__links a { color: var(--muted); font-size: 0.95rem; transition: color 0.2s; }
.nav__links a:hover { color: var(--ink); }
.nav__cta { color: var(--ink) !important; border: 1px solid var(--ink); padding: 0.45rem 1.1rem; border-radius: 4px; }
.nav__cta:hover { background: var(--ink); color: var(--paper) !important; }

/* ---------- hero ---------- */
.hero { position: relative; min-height: 100svh; display: grid; place-items: center; text-align: center; overflow: hidden; }
.hero__texture {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 55% at 50% 18%, rgba(197, 162, 78, 0.16), transparent 60%),
    radial-gradient(90% 70% at 50% 120%, rgba(123, 45, 58, 0.1), transparent 60%),
    linear-gradient(to bottom, var(--paper-2), var(--paper) 55%);
}
.hero__inner { position: relative; z-index: 2; padding: 6rem 1.3rem 2rem; max-width: 900px; }
.hero__title { font-size: clamp(2.6rem, 8vw, 5.4rem); font-weight: 600; letter-spacing: -0.015em; margin-bottom: 1.4rem; }
.hero__greeting {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  margin: 0 auto 1.8rem; min-height: 3.6rem;
}
.hero__hello {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: clamp(1.5rem, 4vw, 2.4rem); color: var(--wine);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.hero__lang {
  font-family: var(--serif); font-size: 0.82rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--gold);
  transition: opacity 0.6s var(--ease);
}
.hero__greeting.is-swapping .hero__hello { opacity: 0; transform: translateY(8px); }
.hero__greeting.is-swapping .hero__lang { opacity: 0; }
.hero__lead { color: var(--muted); font-size: clamp(1.02rem, 2.2vw, 1.2rem); max-width: 600px; margin: 0 auto 2.2rem; }
.hero__actions { display: flex; gap: 0.9rem; justify-content: center; flex-wrap: wrap; }
.hero__scroll { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 2; width: 24px; height: 40px; border: 1.5px solid var(--line); border-radius: 100px; }
.hero__scroll span { position: absolute; top: 8px; left: 50%; width: 4px; height: 8px; margin-left: -2px; border-radius: 4px; background: var(--wine); animation: scrolldot 1.8s infinite; }
@keyframes scrolldot { 0% { opacity: 0; transform: translateY(0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(13px); } }

/* ---------- generic section ---------- */
section { padding: clamp(4.5rem, 11vw, 8rem) clamp(1.1rem, 4vw, 2.5rem); }
.map, .courses, .archive, .community, .support { max-width: var(--maxw); margin: 0 auto; }

/* ---------- map ---------- */
.map__layout { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: stretch; }
.map__board {
  position: relative; border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  background:
    repeating-linear-gradient(45deg, rgba(123, 45, 58, 0.03) 0 2px, transparent 2px 16px),
    linear-gradient(160deg, var(--paper-2), var(--paper-3));
  aspect-ratio: 5 / 3; min-height: 280px;
}
.map__svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.map__land { fill: rgba(30, 42, 74, 0.1); stroke: rgba(30, 42, 74, 0.28); stroke-width: 0.4; stroke-dasharray: 1.4 1; }
/* Real generated map covers the CSS/SVG art (kept underneath as fallback). */
.map__photo {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  z-index: 2; user-select: none; -webkit-user-drag: none;
}
/* Soft paper-toned wash so the wine/gold points stay legible over the photo. */
.map__board::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(160deg, rgba(242, 233, 216, 0.22), rgba(227, 214, 189, 0.32));
  mix-blend-mode: multiply;
}
.map__points { position: absolute; inset: 0; z-index: 4; }
.map__point {
  position: absolute; transform: translate(-50%, -50%);
  width: 18px; height: 18px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--paper); background: var(--wine);
  box-shadow: 0 0 0 0 rgba(123, 45, 58, 0.5);
  transition: transform 0.25s var(--ease), background 0.25s;
  animation: ping 2.6s infinite var(--ease);
  animation-delay: var(--delay, 0s);
}
.map__point::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--gold); opacity: 0.85; }
.map__point:hover, .map__point.is-active { transform: translate(-50%, -50%) scale(1.25); background: var(--ink); animation: none; }
.map__point.is-active::after { background: var(--paper); }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(123, 45, 58, 0.45); }
  70% { box-shadow: 0 0 0 12px rgba(123, 45, 58, 0); }
  100% { box-shadow: 0 0 0 0 rgba(123, 45, 58, 0); }
}
.map__panel {
  border: 1px solid var(--line); border-radius: 16px; padding: clamp(1.3rem, 3vw, 1.9rem);
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  display: flex; flex-direction: column;
}
.map__hint { color: var(--muted); font-style: italic; margin: auto 0; text-align: center; }
.map__card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.map__card h3 { font-size: 1.6rem; }
.map__native {
  font-family: var(--serif); font-style: italic; font-size: 1.15rem; color: var(--wine);
}
.map__region { font-size: 0.86rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); margin: 0.3rem 0 1rem; }
.map__meta { display: grid; gap: 0.55rem; margin-bottom: 1rem; }
.map__meta div { display: flex; gap: 0.6rem; font-size: 0.95rem; }
.map__meta dt { color: var(--muted); flex: none; min-width: 92px; font-style: italic; }
.map__meta dd { color: var(--fg); }
.map__history { font-size: 0.97rem; color: var(--fg); border-top: 1px solid var(--line-soft); padding-top: 0.9rem; }
.map__words { list-style: none; margin-top: 0.9rem; display: grid; gap: 0.4rem; }
.map__words li { font-size: 0.92rem; color: var(--fg); padding-left: 0.9rem; position: relative; }
.map__words li::before { content: "\2022"; position: absolute; left: 0; color: var(--gold); }
.map__words b { color: var(--wine); font-weight: 600; }

.map__list { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: clamp(1.5rem, 4vw, 2.5rem); }
.map__item {
  text-align: left; width: 100%; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.3rem;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  transition: transform 0.3s var(--ease), border-color 0.3s, box-shadow 0.3s;
  font-family: var(--body);
}
.map__item:hover, .map__item.is-active { transform: translateY(-4px); border-color: var(--wine); box-shadow: 0 14px 30px rgba(30, 42, 74, 0.12); }
.map__item h3 { font-size: 1.2rem; margin-bottom: 0.2rem; }
.map__item .map__item-native { font-style: italic; color: var(--wine); font-size: 1rem; }
.map__item .map__item-speakers { display: block; margin-top: 0.5rem; font-size: 0.85rem; color: var(--muted); }

/* ---------- tutor ---------- */
.tutor { position: relative; max-width: var(--maxw); margin: 0 auto; text-align: center; overflow: hidden; border-radius: 22px; }
.tutor__glow { position: absolute; inset: 0; background: radial-gradient(60% 70% at 50% 30%, rgba(197, 162, 78, 0.18), transparent 70%); pointer-events: none; }
.tutor__inner { position: relative; max-width: 720px; margin: 0 auto; }
.tutor__lead { color: var(--fg); font-size: 1.1rem; margin: 1rem auto 2rem; }
.tutor__lead strong { color: var(--wine); font-weight: 700; }
.tutor__chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-bottom: 1.8rem; }
.tutor__chips li { font-style: italic; font-size: 0.92rem; color: var(--ink); padding: 0.5rem 1rem; border: 1px solid var(--line); border-radius: 100px; background: rgba(30, 42, 74, 0.04); }
.tutor__hint { color: var(--muted); font-size: 0.97rem; }
.tutor__dot { color: var(--wine); }

/* ---------- courses ---------- */
.courses__grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.2rem; }
.course {
  position: relative; padding: 2rem 1.7rem; border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  transition: transform 0.4s var(--ease), border-color 0.4s, box-shadow 0.4s;
}
.course:hover { transform: translateY(-6px); border-color: var(--gold); box-shadow: 0 22px 44px rgba(30, 42, 74, 0.14); }
.course__idx { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 1.4rem; }
.course h3 { margin: 0.6rem 0 0.6rem; }
.course p { color: var(--muted); font-size: 0.97rem; min-height: 4.5rem; }
.course__bar { height: 7px; border-radius: 100px; background: rgba(30, 42, 74, 0.1); overflow: hidden; margin: 1.1rem 0 0.7rem; }
.course__fill {
  display: block; height: 100%; width: var(--p, 0%); border-radius: 100px;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  transform-origin: left; transform: scaleX(0);
  transition: transform 1s var(--ease);
}
.is-in .course__fill { transform: scaleX(1); }
.course__meta { font-family: var(--serif); font-style: italic; font-size: 0.85rem; letter-spacing: 0.04em; color: var(--wine); }

/* ---------- archive ---------- */
.archive { position: relative; overflow: hidden; border-radius: 22px; }
/* Real archive texture as a dimmed covering background behind the cards. */
.archive__bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.archive__photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.18; }
/* Paper veil keeps card text fully legible over the texture. */
.archive__bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(242, 233, 216, 0.82), rgba(235, 224, 203, 0.9));
}
.archive > .section-head, .archive__grid { position: relative; z-index: 1; }
.archive__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; align-items: start; }
.archive__card {
  padding: 1.8rem 1.7rem; border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
}
.archive__card h3 { margin-bottom: 0.6rem; }
.archive__card > p { color: var(--muted); font-size: 0.97rem; }
.player { display: flex; align-items: center; gap: 0.8rem; margin: 1.3rem 0 0.9rem; }
/* Honest "coming soon" state — no fake control, just a calm label. */
.player--soon {
  padding: 0.8rem 1rem; border: 1px dashed var(--line); border-radius: 12px;
  background: rgba(30, 42, 74, 0.03);
}
.player__icon { flex: none; width: 24px; height: 24px; color: var(--wine); opacity: 0.7; }
.player__icon svg { width: 100%; height: 100%; }
.player__soon { font-family: var(--serif); font-style: italic; font-size: 0.92rem; color: var(--muted); }
.archive__cap { font-size: 0.85rem; font-style: italic; color: var(--gold); }
.archive__docs { list-style: none; margin-top: 1rem; display: grid; gap: 0.55rem; color: var(--fg); font-size: 0.95rem; }
.archive__docs span { color: var(--gold); margin-right: 0.5rem; }
.archive__stats { display: grid; gap: 0.7rem; margin-top: 1rem; }
.archive__stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line-soft); padding-bottom: 0.5rem; }
.archive__stats dt { color: var(--muted); font-style: italic; font-size: 0.9rem; }
.archive__stats dd { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; color: var(--ink); }

/* ---------- community ---------- */
.community { position: relative; overflow: hidden; }
.community__bg { position: absolute; inset: 0; background: radial-gradient(80% 100% at 50% 0%, var(--paper-2), var(--paper)); }
.community__grid { position: relative; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem; }
.story {
  padding: 1.9rem 1.8rem; border: 1px solid var(--line); border-radius: 14px;
  background: var(--paper);
  position: relative;
}
.story::before { content: "\201C"; position: absolute; top: 0.2rem; left: 1rem; font-family: var(--serif); font-size: 4rem; color: rgba(123, 45, 58, 0.18); line-height: 1; }
.story blockquote { font-family: var(--serif); font-size: 1.1rem; line-height: 1.5; color: var(--ink); position: relative; }
.story footer { margin-top: 1.1rem; font-size: 0.88rem; color: var(--muted); }
.story__name { color: var(--wine); font-style: italic; }

/* ---------- support ---------- */
.support__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.support__card {
  padding: clamp(1.6rem, 4vw, 2.4rem); border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  display: flex; flex-direction: column; gap: 1rem;
}
.support__card p { color: var(--muted); }
.support__amounts { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chip-btn {
  min-height: 44px; padding: 0.5rem 1.1rem; border-radius: 100px; cursor: pointer;
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font-family: var(--serif); font-size: 1rem; transition: background 0.2s, color 0.2s, transform 0.2s;
}
.chip-btn:hover, .chip-btn.is-on { background: var(--ink); color: var(--paper); transform: translateY(-2px); }
.support__list { list-style: none; display: grid; gap: 0.5rem; color: var(--fg); font-size: 0.97rem; }
.support__list li { padding-left: 1.3rem; position: relative; }
.support__list li::before { content: "\2014"; position: absolute; left: 0; color: var(--gold); }
.support__card .btn { align-self: flex-start; margin-top: auto; }

/* ---------- footer ---------- */
.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(3rem, 7vw, 5rem) clamp(1.1rem, 4vw, 2.5rem) 3rem;
  display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.4fr; gap: 2rem;
  border-top: 1px solid var(--line);
}
.footer__brand { display: flex; align-items: center; gap: 0.7rem; font-family: var(--serif); font-weight: 700; letter-spacing: 0.12em; color: var(--ink); }
.footer__brand small { font-family: var(--body); font-weight: 400; font-style: italic; letter-spacing: 0.02em; color: var(--muted); }
.footer h3 { font-size: 0.8rem; font-family: var(--serif); font-style: italic; letter-spacing: 0.14em; text-transform: uppercase; color: var(--wine); margin-bottom: 0.9rem; font-weight: 600; }
.footer__list { list-style: none; color: var(--fg); font-size: 0.95rem; display: grid; gap: 0.5rem; }
.footer__news p { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.9rem; }
.footer__form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.footer__input {
  flex: 1; min-width: 140px; padding: 0.7rem 0.9rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--paper); color: var(--fg);
  font-family: var(--body); font-size: 0.95rem;
}
.footer__input:focus-visible { border-color: var(--wine); }
.footer__msg { font-size: 0.88rem; color: var(--wine); margin-top: 0.6rem; min-height: 1.1rem; }
.footer__rights { grid-column: 1 / -1; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.84rem; font-style: italic; }

/* ---------- reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- chat widget theme (LEXICON) ---------- */
.cw-root { --cw-accent: #7b2d3a; --cw-bg: #1e2a4a; --cw-fg: #f2e9d8; font-family: var(--body) !important; }
.cw-msg.cw-assistant { background: rgba(197, 162, 78, 0.16); }
.cw-fab { color: var(--paper) !important; }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .nav__links a:not(.nav__cta) { display: none; }
  .map__layout { grid-template-columns: 1fr; }
  .map__board { aspect-ratio: 16 / 9; }
  .support__grid { grid-template-columns: 1fr; }
  .footer { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .footer { grid-template-columns: 1fr; }
  .course p { min-height: 0; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none; }
  .hero__scroll span { animation: none; }
  .map__point { animation: none !important; }
  .course__fill { transition: none; transform: scaleX(1) !important; }
  .hero__hello, .hero__lang { transition: none; }
}
