/* Materia Kōgei — pagina "sito in costruzione".
   Gli stili di base sono lo STATO FINALE; le animazioni (fill-mode both) partono dal buio.
   Con prefers-reduced-motion le animazioni si spengono e resta lo stato finale.

   Sequenza (owner 2026-11-18):
     0,15-1,45 s  sfondo da scuro a chiaro (1,3 s)
     1,45-3,95 s  pennellata del cerchio (2,5 s)
     3,95-5,25 s  scritta Materia Kōgei, lettera per lettera (1,3 s)
     5,15-6,5 s   fiore che sboccia: punto al centro (5,15), petali che crescono e si aprono
                  (5,3-6,5), stami che si aprono dal centro (5,95-6,5)
     6,65 s       "Sito in costruzione", poi cambio lingua ogni 4 s
     13,65 s ...  oggetti a pennello e inchiostro (objects.js): partono 7 s dopo la scritta, uno alla volta,
                  20 su desktop e 10 su telefono */

@font-face {
  font-family: "EB Garamond MK";
  src: url("/assets/fonts/eb-garamond-450-latin.woff") format("woff");
  font-weight: 450;
  font-display: swap;
}

:root {
  --night: #1a130e;      /* partenza: bruno quasi nero */
  --paper: #f4eae4;      /* arrivo: tinta chiara del bruno del logo */
  --ink: #57452e;        /* bruno del logo */
  --accent: #b4693a;     /* stami del fiore */
  --ease-brush: cubic-bezier(.45, .05, .3, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --t-ring: 1.45s;
  --t-text: 3.95s;
  --t-flower: 5.15s;
  --t-tagline: 6.65s;   /* objects.js legge questo ritardo dalla .tagline e parte 7 s dopo */
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  animation: dawn 1.3s var(--ease-soft) .15s both;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(.75rem, 3vmin, 2rem);
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  color: var(--ink);
}

/* ---------- logo */
.logo {
  display: block;
  width: min(72vmin, 30rem);
  height: auto;
  overflow: visible;
}

.ring { fill: currentColor; }

.ring-reveal {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 0;
  animation: draw 2.5s var(--ease-brush) var(--t-ring) both;
}

/* 12 lettere in 1,3 s: ognuna si traccia in 0,55 s, una ogni 0,068 s */
.word path {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: .45;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 0;
  --base: var(--t-text);
  --d: 0s;
  animation:
    draw .55s var(--ease-soft) calc(var(--base) + var(--d)) both,
    fill-in .4s var(--ease-soft) calc(var(--base) + var(--d) + .3s) both;
}
.word-2 path { --base: calc(var(--t-text) + .476s); }
.word path:nth-child(2) { --d: .068s; }
.word path:nth-child(3) { --d: .136s; }
.word path:nth-child(4) { --d: .204s; }
.word path:nth-child(5) { --d: .272s; }
.word path:nth-child(6) { --d: .34s; }
.word path:nth-child(7) { --d: .408s; }

/* Fiore che sboccia (owner 2026-11-18): prima un punto al centro, poi i petali escono da quel
   punto, crescono ruotando e si aprono; gli stami, gia' dentro, si aprono dal centro.
   Ogni petalo e' un <g class="petal"> attorno al path (il path tiene la sua posizione). */
.petals path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linejoin: round;
}
:is(.petals, .flower-knock) .petal {
  transform-box: view-box;
  transform-origin: 353.8px 353.8px;  /* centro del fiore nel viewBox 465 */
  --d: 0s;
  animation: unfurl 1s cubic-bezier(.2, .7, .25, 1) calc(var(--t-flower) + .15s + var(--d)) both;
}
:is(.petals, .flower-knock) .petal:nth-child(2) { --d: .05s; }
:is(.petals, .flower-knock) .petal:nth-child(3) { --d: .1s; }
:is(.petals, .flower-knock) .petal:nth-child(4) { --d: .15s; }
:is(.petals, .flower-knock) .petal:nth-child(5) { --d: .2s; }

.filaments, .anthers {
  transform-box: view-box;
  transform-origin: 353.8px 353.8px;
  animation: stamens-open .55s cubic-bezier(.25, .8, .3, 1.15) calc(var(--t-flower) + .8s) both;
}
.pistil {
  transform-box: fill-box;
  transform-origin: center;
  animation: dot .3s cubic-bezier(.3, 1.5, .5, 1) var(--t-flower) both;
}
.filaments { fill: none; stroke: var(--accent); stroke-width: 1.1; stroke-linecap: round; }
.anthers { fill: var(--accent); }
.pistil { fill: currentColor; }

/* ---------- testo sotto il logo: descrizione + stato, italiano <-> inglese in dissolvenza, 4 s per lingua */
.tagline {
  margin: 0;
  display: grid;
  justify-items: center;
  font-family: "EB Garamond MK", "EB Garamond", Garamond, "Times New Roman", serif;
  font-weight: 450;
  text-align: center;
  animation: rise .9s var(--ease-soft) var(--t-tagline) both;
}
.tag { display: grid; justify-items: center; gap: .6em; }
.desc {
  font-size: clamp(1rem, .86rem + .7vw, 1.45rem);
  letter-spacing: .04em;
}
.status {
  font-size: clamp(.7rem, .62rem + .4vw, .92rem);
  letter-spacing: .32em;
  text-transform: uppercase;
  padding-left: .32em; /* compensa lo spazio dopo l'ultima lettera */
}
/* Base (senza animazioni, stampa, movimento ridotto): le due lingue una sotto l'altra.
   Solo quando il movimento e' permesso si sovrappongono e si alternano. */
.tag-en { margin-top: 1.2em; }
@media (prefers-reduced-motion: no-preference) {
  .tag { grid-area: 1 / 1; animation: 8s var(--ease-soft) calc(var(--t-tagline) + .6s) infinite both; }
  .tag-en { margin-top: 0; }
  .tag-it { animation-name: swap-a; }
  .tag-en { animation-name: swap-b; }
}

/* ---------- contatto, fisso sotto il testo */
.contact {
  margin: 0;
  font-family: "EB Garamond MK", "EB Garamond", Garamond, "Times New Roman", serif;
  font-weight: 450;
  font-size: clamp(.85rem, .78rem + .3vw, 1rem);
  letter-spacing: .06em;
  animation: rise .9s var(--ease-soft) calc(var(--t-tagline) + .5s) both;
}
.contact a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(87, 69, 46, .35);
  padding-bottom: .1em;
}
.contact a:hover { border-bottom-color: currentColor; }
.contact a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 2px; }

/* ---------- oggetti a pennello e inchiostro: posizione, dimensione e forma li decide objects.js */
.objects {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.obj {
  position: absolute;
  opacity: 0;           /* acceso da objects.js quando parte il disegno */
  transition: opacity .3s linear;
}
.obj.is-on { opacity: 1; }
.obj svg { display: block; width: 100%; height: 100%; overflow: visible; }
.obj .ink { fill: #6b5844; }   /* bruno del logo, piu' leggero */
.obj .reveal {                 /* nella maschera: scopre l'inchiostro lungo la linea centrale */
  fill: none;
  stroke: #fff;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Niente filtri SVG: lavorano a pixel e sgranavano il tratto (owner 2026-11-18). */

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

/* ---------- keyframes */
@keyframes dawn { from { background-color: var(--night); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes fill-in { from { fill-opacity: 0; } }
@keyframes appear { from { opacity: 0; } }
@keyframes unfurl {
  0%   { opacity: 0; transform: rotate(-75deg) scale(0); }
  12%  { opacity: 1; }
  55%  { transform: rotate(-14deg) scale(.72); }
  100% { transform: none; }
}
@keyframes stamens-open { from { opacity: 0; transform: scale(0) rotate(-35deg); } }
@keyframes dot { from { opacity: 0; transform: scale(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(.6em); filter: blur(3px); } }
@keyframes swap-a {
  0%, 42% { opacity: 1; filter: blur(0); }
  50%, 92% { opacity: 0; filter: blur(2px); }
  100% { opacity: 1; filter: blur(0); }
}
@keyframes swap-b {
  0%, 42% { opacity: 0; filter: blur(2px); }
  50%, 92% { opacity: 1; filter: blur(0); }
  100% { opacity: 0; filter: blur(2px); }
}
/* ---------- movimento ridotto: stato finale, entrambe le lingue visibili (base di .tag) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
