/* ============================================================
   AION NYN — Design System
   Tokens, typography, primitives, shell (nav / footer / forms)
   ============================================================ */

/* Intensità della luce che raggiunge un'opera: 0 = buio, 1 = illuminata.
   Registrata come proprietà così da poter essere animata. */
@property --lit {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

:root {
  /* ---- Palette -------------------------------------------- */
  --ink:        #05060a;   /* nero profondo */
  --ink-2:      #080a10;
  --night:      #0b1220;   /* blu notte */
  --night-2:    #0e1626;
  --anthracite: #14161a;
  --stone:      #22201d;
  --stone-2:    #322e28;
  --ivory:      #ece4d5;
  --ivory-dim:  #b9b1a2;
  --muted:      #7d776d;
  --gold:       #b3945c;   /* oro caldo, metallo antico */
  --gold-lit:   #d8bd86;
  --gold-veil:  rgba(179, 148, 92, 0.28);
  --water:      #7f9aa3;

  --line:       rgba(179, 148, 92, 0.18);
  --line-soft:  rgba(236, 228, 213, 0.09);

  /* ---- Typography -----------------------------------------
     Una sola scala per tutto il sito: nessun titolo fuori misura,
     nessun testo troppo piccolo. --t-verse è la riga narrativa
     (discesa, tempio, territori, ciclo), il registro intermedio
     fra un titolo e un paragrafo. */
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia,
           "Songti SC", "Hiragino Mincho ProN", "Yu Mincho", "Nanum Myeongjo", serif;
  --sans:  "Jost", "Avenir Next", "Segoe UI", "Helvetica Neue",
           "PingFang SC", "Hiragino Sans", "Noto Sans KR", sans-serif;

  --t-display: clamp(3rem, 7.4vw, 5.8rem);
  --t-h1:      clamp(2.1rem, 4.2vw, 3.4rem);
  --t-h2:      clamp(1.75rem, 3.1vw, 2.6rem);
  --t-h3:      clamp(1.3rem, 1.8vw, 1.6rem);
  --t-verse:   clamp(1.3rem, 2.2vw, 2rem);
  --t-lead:    clamp(1.1rem, 1.45vw, 1.4rem);
  --t-body:    clamp(1rem, 1.05vw, 1.075rem);
  --t-small:   0.9rem;
  --t-label:   0.75rem;

  --track-label: 0.3em;
  --track-brand: 0.34em;

  /* ---- Space ---------------------------------------------- */
  --s-1: 0.5rem;
  --s-2: 1rem;
  --s-3: 1.75rem;
  --s-4: 2.75rem;
  --s-5: 4.5rem;
  --s-6: 7rem;
  --s-7: 11rem;
  --s-8: 17rem;

  --gutter: clamp(1.25rem, 4.2vw, 4.5rem);
  --max: 1340px;
  --measure: 34rem;
  --nav-h: 78px;

  /* ---- Motion --------------------------------------------- */
  --ease: cubic-bezier(0.16, 0.68, 0.28, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --d-1: 420ms;
  --d-2: 900ms;
  --d-3: 1600ms;
  --d-4: 2600ms;

  /* Texture della roccia, condivisa da grotta e pagina opera */
  --rock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320'%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.032 0.06' numOctaves='4' seed='7'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='320' height='320' filter='url(%23r)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--sans);
  font-weight: 300;
  font-size: var(--t-body);
  line-height: 1.65;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2, h3, p, figure, blockquote { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

::selection { background: var(--gold-veil); color: var(--ivory); }

:focus-visible {
  outline: 1px solid var(--gold-lit);
  outline-offset: 4px;
}

/* Full-viewport grain: fixed and non-interactive, never inside a scroller */
body::after {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 60;
  pointer-events: none;
  opacity: 0.028;
  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.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Layout primitives ------------------------------------- */
.wrap {
  width: min(100% - (var(--gutter) * 2), var(--max));
  margin-inline: auto;
}

.wrap--narrow { max-width: 62rem; }

.chapter {
  position: relative;
  isolation: isolate;
}

/* ---- Type primitives --------------------------------------- */
.label {
  font-family: var(--sans);
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--gold);
  display: block;
}

.display {
  font-family: var(--serif);
  font-weight: 300;
  font-size: var(--t-display);
  line-height: 0.98;
  letter-spacing: var(--track-brand);
  margin-inline-end: calc(var(--track-brand) * -1);
}

.h1 { font-family: var(--serif); font-weight: 300; font-size: var(--t-h1); line-height: 1.05; }
.h2 { font-family: var(--serif); font-weight: 300; font-size: var(--t-h2); line-height: 1.1; }
.h3 { font-family: var(--serif); font-weight: 400; font-size: var(--t-h3); line-height: 1.25; }

.lead {
  font-family: var(--serif);
  font-size: var(--t-lead);
  line-height: 1.5;
  color: #ddd5c5;
  font-weight: 300;
}

.prose {
  max-width: var(--measure);
  color: var(--ivory-dim);
  line-height: 1.8;
}
.prose + .prose { margin-top: var(--s-3); }

.rule {
  height: 1px;
  border: 0;
  margin: var(--s-4) 0;
  background: linear-gradient(90deg, var(--gold-veil), rgba(179, 148, 92, 0.02) 70%, transparent);
}

/* ---- Buttons ----------------------------------------------- */
.btn {
  --btn-fg: var(--ivory);
  display: inline-flex;
  align-items: center;
  gap: 0.85em;
  padding: 1.05em 1.9em;
  border: 1px solid var(--line);
  color: var(--btn-fg);
  font-size: var(--t-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  transition: color var(--d-1) var(--ease), border-color var(--d-1) var(--ease);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(179, 148, 92, 0.16), rgba(179, 148, 92, 0.04));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--d-2) var(--ease);
  z-index: -1;
}
.btn:hover { border-color: var(--gold); color: var(--gold-lit); }
.btn:hover::before { transform: scaleX(1); }
.btn:active { transform: translateY(1px); }

.btn--solid {
  background: linear-gradient(140deg, rgba(179, 148, 92, 0.9), rgba(140, 113, 66, 0.85));
  border-color: transparent;
  color: #0d0b07;
  font-weight: 400;
}
.btn--solid:hover { color: #0d0b07; filter: brightness(1.08); }

.btn--quiet { border-color: var(--line-soft); color: var(--ivory-dim); }

.link-underline {
  display: inline-block;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--gold-veil);
  font-size: var(--t-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  transition: border-color var(--d-1) var(--ease), color var(--d-1) var(--ease);
}
.link-underline:hover { border-color: var(--gold); color: var(--gold-lit); }

/* ---- Status pills ------------------------------------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-size: var(--t-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}
.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}
.pill[data-status="available"],
.pill[data-status="limited"],
.pill[data-status="unique"] { color: var(--gold-lit); }
.pill[data-status="sold"],
.pill[data-status="notForSale"] { color: var(--muted); }

/* ---- Reveal on scroll -------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition:
    opacity var(--d-3) var(--ease),
    transform var(--d-3) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal].is-revealed {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.skip {
  position: fixed;
  top: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 90;
  padding: 0.75rem 1.1rem;
  background: var(--anthracite);
  border: 1px solid var(--line);
  font-size: var(--t-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  transform: translateY(-160%);
  transition: transform var(--d-1) var(--ease);
}
.skip:focus { transform: translateY(0); }

.nav {
  position: fixed;
  z-index: 50;
  top: 0;
  inset-inline: 0;
  transition: background var(--d-2) var(--ease-soft), backdrop-filter var(--d-2) var(--ease-soft);
}
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(5, 6, 10, 0.82), rgba(5, 6, 10, 0.28) 55%, transparent);
  opacity: 0;
  transition: opacity var(--d-2) var(--ease-soft);
  pointer-events: none;
}
.nav.is-stuck::before { opacity: 1; }
.nav.is-stuck { backdrop-filter: blur(9px); }

.nav__in {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  position: relative;
}

.brand {
  font-family: var(--serif);
  font-size: 1.02rem;
  letter-spacing: 0.4em;
  color: var(--ivory);
  white-space: nowrap;
}
.brand span { color: var(--gold); }

.nav__links {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.2vw, 2.2rem);
  font-size: var(--t-label);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #cdc5b5;
}
.nav__links a {
  position: relative;
  padding-block: 0.4em;
  transition: color var(--d-1) var(--ease);
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: inline-start;
  transition: transform var(--d-2) var(--ease);
}
.nav__links a:hover { color: var(--gold-lit); }
.nav__links a:hover::after,
.nav__links a.is-current::after { transform: scaleX(1); }

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

/* Language selector */
.lang {
  position: relative;
}
.lang__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 0.9em;
  border: 1px solid var(--line);
  font-size: var(--t-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory);
  transition: border-color var(--d-1) var(--ease), color var(--d-1) var(--ease);
}
.lang__toggle:hover { border-color: var(--gold); color: var(--gold-lit); }
.lang__toggle svg { width: 9px; height: 9px; opacity: 0.7; transition: transform var(--d-1) var(--ease); }
.lang__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.lang__menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  inset-inline-end: 0;
  min-width: 12.5rem;
  padding: 0.5rem;
  background: rgba(10, 11, 15, 0.96);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: grid;
  gap: 1px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--d-1) var(--ease), transform var(--d-1) var(--ease), visibility var(--d-1);
  max-height: 60vh;
  overflow-y: auto;
}
.lang__menu.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
.lang__menu button {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  width: 100%;
  padding: 0.7em 0.85em;
  text-align: start;
  font-size: 0.8rem;
  color: var(--ivory-dim);
  transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease);
}
.lang__menu button:hover { background: rgba(179, 148, 92, 0.09); color: var(--ivory); }
.lang__menu button[aria-current="true"] { color: var(--gold-lit); }
.lang__menu button span:last-child {
  font-size: var(--t-label);
  letter-spacing: 0.18em;
  opacity: 0.5;
}

/* Mobile menu */
.nav__burger {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  position: relative;
}
.nav__burger i {
  position: absolute;
  left: 11px;
  width: 18px;
  height: 1px;
  background: var(--ivory);
  transition: transform var(--d-1) var(--ease), opacity var(--d-1) var(--ease);
}
.nav__burger i:nth-child(1) { top: 16px; }
.nav__burger i:nth-child(2) { top: 24px; }
.nav__burger[aria-expanded="true"] i:nth-child(1) { transform: translateY(4px) rotate(45deg); }
.nav__burger[aria-expanded="true"] i:nth-child(2) { transform: translateY(-4px) rotate(-45deg); }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: linear-gradient(160deg, var(--night), var(--ink) 60%);
  padding: calc(var(--nav-h) + 2rem) var(--gutter) 3rem;
  display: grid;
  align-content: center;
  gap: 0.35rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--d-2) var(--ease), visibility var(--d-2);
}
.drawer.is-open { opacity: 1; visibility: visible; }
.drawer a {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 7vw, 2.6rem);
  font-weight: 300;
  padding-block: 0.35em;
  border-bottom: 1px solid var(--line-soft);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--d-2) var(--ease), transform var(--d-2) var(--ease);
}
.drawer.is-open a { opacity: 1; transform: translateY(0); }
.drawer a:nth-child(1) { transition-delay: 60ms; }
.drawer a:nth-child(2) { transition-delay: 110ms; }
.drawer a:nth-child(3) { transition-delay: 160ms; }
.drawer a:nth-child(4) { transition-delay: 210ms; }
.drawer a:nth-child(5) { transition-delay: 260ms; }
.drawer a:nth-child(6) { transition-delay: 310ms; }
.drawer a:nth-child(7) { transition-delay: 360ms; }
.drawer a:nth-child(8) { transition-delay: 410ms; }

body.is-locked { overflow: hidden; }

/* ============================================================
   FORMS
   ============================================================ */
.form { display: grid; gap: var(--s-3); }
.form__row { display: grid; gap: var(--s-3); grid-template-columns: 1fr 1fr; }

.field { display: grid; gap: 0.55rem; }
.field > label {
  font-size: var(--t-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.95em 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ivory);
  font-family: var(--serif);
  font-size: 1.15rem;
  transition: border-color var(--d-1) var(--ease);
}
.field textarea { resize: vertical; min-height: 7rem; line-height: 1.6; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--gold);
}
.field select option { background: var(--anthracite); color: var(--ivory); }
.field.has-error input,
.field.has-error textarea { border-color: #a4543f; }
.field__error {
  font-size: var(--t-small);
  color: #c07a63;
  min-height: 1.1em;
}

.form__note { font-size: var(--t-small); color: var(--muted); max-width: 34rem; }
.form__status {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--gold-lit);
  min-height: 1.6em;
}
.form__status[data-state="error"] { color: #c07a63; }

.honey { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  padding: var(--s-6) 0 var(--s-4);
  background: var(--ink);
  border-top: 1px solid var(--line-soft);
  position: relative;
}
.footer__credo {
  font-family: var(--serif);
  font-size: var(--t-lead);
  font-weight: 300;
  line-height: 1.55;
  color: #cfc7b7;
  max-width: 46rem;
}
.footer__grid {
  margin-top: var(--s-5);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3);
  align-items: baseline;
  font-size: var(--t-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.footer__grid a:hover { color: var(--gold-lit); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  :root { --nav-h: 64px; }
  .nav__links { display: none; }
  .nav__burger { display: block; }
  .form__row { grid-template-columns: 1fr; }
}

@media (min-width: 901px) {
  .drawer { display: none; }
}

/* ============================================================
   RTL
   ============================================================ */
[dir="rtl"] .display,
[dir="rtl"] .brand { letter-spacing: 0.12em; margin-inline-end: 0; }
[dir="rtl"] .label,
[dir="rtl"] .btn,
[dir="rtl"] .nav__links,
[dir="rtl"] .link-underline,
[dir="rtl"] .pill,
[dir="rtl"] .field > label,
[dir="rtl"] .footer__grid { letter-spacing: 0; }
[dir="rtl"] .lang__toggle { letter-spacing: 0; }
[dir="rtl"] body { font-family: "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", Tahoma, sans-serif; }
[dir="rtl"] .display,
[dir="rtl"] .h1,
[dir="rtl"] .h2,
[dir="rtl"] .h3,
[dir="rtl"] .lead,
[dir="rtl"] .footer__credo,
[dir="rtl"] .field input,
[dir="rtl"] .field textarea { font-family: "Noto Naskh Arabic", "Geeza Pro", Georgia, serif; }

/* Latin wordmark stays LTR inside RTL layouts */
[dir="rtl"] .brand,
[dir="rtl"] .display { direction: ltr; unicode-bidi: isolate; }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}
