/* ==========================================================================
   gallozzi.fun — stile condiviso
   Indice: 1. Font  2. Colori e misure  3. Base  4. Locandina  5. Pulsanti
           6. Animazioni  7. Browser più vecchi  8. Schermi piccoli
   ========================================================================== */

/* 1. Font (ospitati in locale: niente Google Fonts, per privacy) ---------- */
@font-face {
  font-family: "Vale Ale Lettering"; /* lettering su misura: solo i caratteri di "save the date!" e della data */
  src: url("../assets/fonts/vale-ale-lettering.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Patrick Hand"; /* SIL Open Font License, vedi assets/fonts/OFL-patrick-hand.txt */
  src: url("../assets/fonts/patrick-hand.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* 2. Colori e misure ------------------------------------------------------- */
:root {
  --paper: #F5EEE2;   /* carta della locandina */
  --cream: #FAF5EC;   /* pulsanti su fondo blu */
  --ink: #B64D38;     /* rosso mattone: scritte e disegno */
  --slate: #3F5E72;   /* nomi */
  --blue: #244A63;    /* muro */
  --gold: #D3A03B;    /* luccichio dell'anello, focus */
  --line: rgba(182, 77, 56, .58);
  --shadow: 0 32px 100px rgba(6, 22, 34, .32), 0 8px 24px rgba(6, 22, 34, .16);

  --font-lettering: "Vale Ale Lettering", "Patrick Hand", system-ui, sans-serif;
  --font-hand: "Patrick Hand", system-ui, sans-serif;
}

/* 3. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--blue); }
p { margin: 0; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(16px, 3vh, 32px);
  padding: clamp(16px, 3svh, 32px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  align-content: center;
  row-gap: 20px;
  overflow-x: hidden;
  background: var(--blue) url("../assets/img/sfondo.png") center top / 480px repeat;
  color: var(--ink);
  font-family: var(--font-hand);
  text-align: center;
}

/* 4. Locandina ------------------------------------------------------------- */
.card {
  position: relative;
  z-index: 2;
  container-type: inline-size; /* le misure in cqw seguono la larghezza della locandina */
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.3vh, 16px);              /* le righe in vh sono la riserva */
  gap: clamp(8px, 1.3svh, 16px);             /* per i browser che non conoscono svh */
  /* larghezza massima: quella che fa stare locandina + pulsante nell'altezza dello schermo
     (64px = pulsante + spazio sopra; 1.6 = proporzione altezza/larghezza della locandina) */
  --fit: calc((100vh - 2 * clamp(16px, 3vh, 32px) - 64px) / 1.6);
  --fit: calc((100svh - 2 * clamp(16px, 3svh, 32px) - 64px) / 1.6);
  width: min(100%, 510px, var(--fit));
  padding: clamp(24px, 4vh, 38px) clamp(22px, 3vh, 34px);
  padding: clamp(24px, 4svh, 38px) clamp(22px, 3svh, 34px);
  background: var(--paper);
  box-shadow: var(--shadow);
  transform: rotate(-1.5deg); /* locandina "appesa" leggermente storta */
  transition: transform .4s ease;
}
/* Si raddrizza: col mouse quando ci passi sopra, su telefono quando la tocchi (js/main.js) */
@media (hover: hover) {
  .card:hover { transform: rotate(0deg) scale(1.01); }
}
.card.is-touched { transform: rotate(0deg) scale(1.01); }
.card::before { /* grana della carta */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url("../assets/img/carta.jpg") center / cover;
  opacity: .42;
  mix-blend-mode: multiply;
}
.card::after { /* filetto interno */
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(182, 77, 56, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  pointer-events: none;
}

header {
  display: grid;
  place-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 auto;
  padding-top: 2px;
}
h1 {
  margin: 0;
  font: normal 16cqw / .98 var(--font-lettering);
  color: var(--ink);
  transform: rotate(-3deg);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .2));
}
h1 span { display: block; width: max-content; max-width: 100%; margin: auto; }
.top { position: relative; }

.rays {
  position: absolute;
  top: 40%;
  width: clamp(28px, 8cqw, 46px);
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.rays--left  { left: -11.5cqw; }
.rays--right { right: -11cqw; }

.portrait {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  overflow: hidden;
}
.glint {
  fill: var(--gold);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.4cqw;
  width: 100%;
  min-width: 0;
  margin-top: auto;
}
.names {
  color: var(--slate);
  font-size: 10cqw;
  line-height: 1.08;
  white-space: nowrap;
  -webkit-text-stroke: .014em currentColor; /* un filo più "pieno" del font */
}
.divider, .date, .signoff { width: 88%; margin-inline: auto; }

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4cqw, 18px);
  margin-top: 2px;
  color: var(--ink);
}
.divider::before, .divider::after {
  content: "";
  flex: 1 1 auto;
  min-width: 0;
  height: 1px;
  background: currentColor;
  opacity: .72;
}
.divider svg {
  display: block;
  flex: 0 0 auto;
  width: 5.5cqw;
  height: auto;
  fill: currentColor;
  fill-opacity: 0;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.date {
  display: grid;
  place-items: center;
  padding: .25rem 0 .35rem;
  color: var(--ink);
  font-family: var(--font-lettering);
  font-size: 9cqw;
  letter-spacing: .015em;
  line-height: 1.12;
  text-transform: uppercase;
  font-variant-numeric: lining-nums;
}
.signoff {
  padding-top: 3cqw;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 5.2cqw;
  line-height: 1.34;
}

/* 5. Pulsanti (sul muro blu) ---------------------------------------------- */
.google-calendar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 12px 20px;
  background: var(--cream);
  color: var(--blue);
  border: 1px solid var(--cream);
  border-radius: 4px;
  font-family: var(--font-hand);
  font-size: 20px;
  text-decoration: none;
}
.google-calendar:hover { text-decoration: underline; text-underline-offset: 3px; }
.google-calendar:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

/* 6. Animazioni (solo se il dispositivo non chiede movimento ridotto) ------ */
@media (prefers-reduced-motion: no-preference) {
  header     { animation: intro .6s cubic-bezier(.2, .7, .2, 1) both; }
  h1         { animation: writeTitle 1.1s cubic-bezier(.2, .7, .2, 1) .15s both; transform-origin: center; }
  .reveal    { animation: drawIn 1.35s cubic-bezier(.2, .65, .25, 1) .35s both; }
  .names     { animation: intro .55s ease-out 1.2s both; }
  .divider   { animation: intro .5s ease-out 1.36s both; }
  .date      { animation: intro .5s ease-out 1.52s both; }
  .signoff   { animation: intro .5s ease-out 1.68s both; }
  .glint     { animation: sparkle 2.4s ease-in-out 1.4s infinite; }
  .divider svg { animation: starFill 2.4s ease-in-out 1.4s infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}
@keyframes writeTitle { /* il titolo si "scrive" da sinistra */
  from { opacity: 0; clip-path: inset(-15% 100% -15% -15%); }
  to   { opacity: 1; clip-path: inset(-15% -15% -15% -15%); }
}
@keyframes drawIn { /* il disegno compare da sinistra */
  from { opacity: 0; clip-path: inset(0 100% 0 0); }
  to   { opacity: 1; clip-path: inset(0 0 0 0); }
}
@keyframes intro {
  from { opacity: 0; translate: 0 12px; }
  to   { opacity: 1; translate: 0 0; }
}
@keyframes sparkle { /* luccichio dell'anello */
  0%, 8%, 21%, 100% { opacity: 0;   transform: scale(.35) rotate(-16deg); }
  11%               { opacity: .95; transform: scale(1.12) rotate(0deg); }
  15%               { opacity: .85; transform: scale(.82) rotate(8deg); }
  18%               { opacity: .25; transform: scale(1.02) rotate(12deg); }
}
@keyframes starFill { /* la stellina si riempie */
  0%, 55%, 100% { fill-opacity: 0; }
  22%, 35%      { fill-opacity: 1; }
}

/* 7. Browser più vecchi (es. iPhone fermi a iOS 15) ----------------------
   Non conoscono le unità cqw: qui le stesse misure sono riscritte in base
   alla larghezza dello schermo, con un risultato quasi identico. */
@supports not (width: 1cqw) {
  :root {
    --fit-old: calc((100vh - 2 * clamp(16px, 3vh, 32px) - 64px) / 1.6);
    --u: calc((min(100vw - 32px, 510px, var(--fit-old)) - 48px) / 100);
  }
  @media (max-width: 820px) {
    :root { --u: calc((min(100vw - 32px, 470px, var(--fit-old)) - 44px) / 100); }
  }
  h1            { font-size: calc(16 * var(--u)); }
  .rays         { width: clamp(28px, calc(8 * var(--u)), 46px); }
  .rays--left   { left: calc(-11.5 * var(--u)); }
  .rays--right  { right: calc(-11 * var(--u)); }
  footer        { gap: calc(2.4 * var(--u)); }
  .names        { font-size: calc(10 * var(--u)); }
  .divider      { gap: clamp(10px, calc(2.4 * var(--u)), 18px); }
  .divider svg  { width: calc(5.5 * var(--u)); }
  .date         { font-size: calc(9 * var(--u)); }
  .signoff      { font-size: calc(5.2 * var(--u)); padding-top: calc(3 * var(--u)); }
}

/* 8. Schermi piccoli ------------------------------------------------------- */
@media (max-width: 820px) {
  .card { width: min(100%, 470px, var(--fit)); }
}
@media (max-width: 420px) {
  .card::after { inset: 10px; }
  .rays--left  { left: -12.5cqw; }
  .rays--right { right: -12cqw; }
}
