/* ==========================================================================
   Appuntamy — sistema visivo condiviso (landing + pagina grazie)

   Porting fedele di src/app/globals.css e dei componenti del sito
   principale (Wordmark, Header, Footer, WaveDivider, Rich). Stessi token
   OKLCH, stessa scala tipografica, stessi bottoni e movimenti. Se cambia
   il sito principale, si aggiorna qui: le due pagine leggono solo questo.
   ========================================================================== */

:root {
  color-scheme: light;

  /* --- Superfici e inchiostro (identici al sito) ----------------------- */
  --bg: oklch(1 0 0);
  --ink: oklch(0.185 0.014 62);
  --muted: oklch(0.475 0.016 62);
  --line: oklch(0.885 0.01 62);
  --surface: oklch(0.972 0.006 72);

  /* --- Marchio ---------------------------------------------------------- */
  --honey: oklch(0.795 0.145 74);
  --honey-deep: oklch(0.55 0.135 60);
  --on-honey-muted: oklch(0.36 0.055 62);
  --cream: oklch(0.965 0.045 95); /* pillole e linguette sul miele */
  --postit: oklch(0.955 0.065 95);

  /* --- Accento ---------------------------------------------------------- */
  --pine: oklch(0.455 0.098 168);
  --pine-soft: oklch(0.94 0.032 168);
  /* Unica aggiunta alla palette: il rosso della perdita, preso dagli
     annunci della campagna (stesso tono del bollino «Caso reale»). Solo
     per i margini negativi, sempre accompagnato dal segno «−». */
  --loss: oklch(0.52 0.17 30);
  --loss-soft: oklch(0.95 0.03 30);

  /* --- Tipografia ------------------------------------------------------- */
  --font-display: "Bricolage Grotesque", "Helvetica Neue", sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --font-hand: "Caveat", "Bradley Hand", cursive;

  /* Scala del sito, con il display un gradino sotto: qui il titolo divide
     la riga con il modulo, non occupa tutta la pagina. */
  --step-display: clamp(2.5rem, 1.35rem + 4.4vw, 4.6rem);
  --step-h2: clamp(2rem, 1.25rem + 2.9vw, 3.3rem);
  --step-h3: clamp(1.3rem, 1.12rem + 0.7vw, 1.6rem);
  --step-lead: clamp(1.15rem, 1.06rem + 0.45vw, 1.4rem);
  --step-body: 1.125rem;
  --step-small: 1rem;
  --step-tiny: 0.8125rem;

  --track-display: -0.03em;
  --track-h2: -0.025em;
  --track-h3: -0.015em;
  --track-lead: -0.01em;
  --track-small: 0.005em;
  --track-tiny: 0.012em;

  /* --- Spazio ----------------------------------------------------------- */
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --max: 1200px;
  --section-y: clamp(4.5rem, 9vw, 7rem);
  --section-y-tight: clamp(3rem, 6vw, 4.5rem);

  /* --- Forma ------------------------------------------------------------ */
  --r-control: 8px;
  --r-panel: 12px;
  --r-paper: 12px 15px 13px 16px / 15px 12px 16px 13px; /* carta, non card */

  --lift: 0 1px 2px oklch(0.185 0.014 62 / 0.05),
    0 10px 28px -10px oklch(0.185 0.014 62 / 0.16);
  --lift-high: 0 2px 4px oklch(0.185 0.014 62 / 0.05),
    0 20px 48px -16px oklch(0.185 0.014 62 / 0.2);

  /* --- Movimento -------------------------------------------------------- */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.55, 0.64, 1);
  --t-fast: 180ms;
  --t-base: 320ms;
  --t-slow: 520ms;

  --z-sticky: 100;
  --z-nav: 200;
}

/* --- Reset mirato ------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;
  scroll-padding-top: 5.5rem;
}

body {
  background-color: var(--bg);
  /* La carta a quadretti dell'agenda, come sul sito. */
  background-image:
    linear-gradient(oklch(0.185 0.014 62 / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.185 0.014 62 / 0.04) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-body);
  line-height: 1.6;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-optical-sizing: auto;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-display);
  font-weight: 800;
  line-height: 1;
  letter-spacing: var(--track-display);
}

h2 {
  font-size: var(--step-h2);
  line-height: 1.06;
  letter-spacing: var(--track-h2);
}

h3 {
  font-size: var(--step-h3);
  line-height: 1.2;
  letter-spacing: var(--track-h3);
}

p { text-wrap: pretty; }

.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); }

:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Logotipo -----------------------------------------------------------
   Il simbolo è il file originale (icon.png del sito), mai ridisegnato: si
   fissa solo l'altezza, la larghezza segue. Il logotipo è il componente
   Wordmark del sito: Bricolage 800 e il punto in miele scuro.
   ----------------------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  padding-block: 0.55rem;
  margin-block: -0.55rem;
}

.brand-icon {
  height: 1.75rem;
  width: auto;
  flex: none;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}

.wordmark .dot { color: var(--honey-deep); }

/* --- Header -------------------------------------------------------------
   Come sul sito: trasparente sul campo miele, strato traslucido quando si
   scorre. Marchio a sinistra, una linguetta crema a destra.
   ----------------------------------------------------------------------- */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: transparent;
  transition: background-color var(--t-base) var(--ease);
}

.header.is-scrolled {
  background: oklch(1 0 0 / 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.header::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto 0;
  height: 1.5rem;
  pointer-events: none;
  opacity: 0;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  -webkit-mask-image: linear-gradient(to bottom, rgb(0 0 0), transparent);
  mask-image: linear-gradient(to bottom, rgb(0 0 0), transparent);
  transition: opacity var(--t-base) var(--ease);
}

.header.is-scrolled::after { opacity: 1; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  background: var(--cream);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 1.05rem;
  font-size: var(--step-small);
  letter-spacing: var(--track-small);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

@media (prefers-reduced-transparency: reduce) {
  .header.is-scrolled {
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .header { background: var(--bg); border-bottom: 1px solid var(--ink); }
}

/* --- Bottoni (identici al sito) ----------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  max-width: 100%;
  padding: 0.75rem 1.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: var(--step-body);
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    translate 300ms var(--ease-spring),
    box-shadow 300ms var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { translate: 0 -3px; box-shadow: var(--lift); }
}

.btn:active {
  translate: 0 1px;
  transition-duration: var(--t-fast), var(--t-fast), 80ms, 80ms;
}

.btn:disabled { cursor: progress; opacity: 0.8; translate: none; box-shadow: none; }

.btn-lg {
  min-height: 3.5rem;
  padding: 0.9rem 2rem;
  font-size: 1.2rem;
  font-weight: 700;
}

@media (max-width: 30rem) {
  .btn { white-space: normal; padding-inline: 1.15rem; text-align: center; }
  .btn-lg { padding-inline: 1.35rem; font-size: 1.125rem; }
}

.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: oklch(0.29 0.03 62); }

.btn-on-honey { background: var(--ink); color: var(--honey); }
.btn-on-honey:hover { background: oklch(0.29 0.03 62); }

.btn-on-ink { background: var(--honey); color: var(--ink); }
.btn-on-ink:hover { background: oklch(0.85 0.13 78); }

/* --- Annotazioni a mano: solo a margine, mai informazioni necessarie ---- */

.hand {
  font-family: var(--font-hand);
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 600;
}

/* --- La parola evidenziata (componente Rich del sito) -------------------- */

.em {
  font-style: normal;
  color: var(--honey-deep);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8.5 C 24 5 44 9.5 62 7 C 82 4.5 102 8.5 117 6' fill='none' stroke='%23a8631d' stroke-width='4.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.14em;
  padding-bottom: 0.1em;
}

@supports (animation-timeline: view()) {
  .em {
    animation: em-tratto both linear;
    animation-timeline: view();
    animation-range: entry 30% entry 90%;
  }
}

@keyframes em-tratto {
  from { background-size: 0% 0.14em; }
  to { background-size: 100% 0.14em; }
}

/* --- Ingressi legati allo scorrimento (solo dove supportati) ------------- */

@supports (animation-timeline: view()) {
  :is(.rise, .rise-2, .fade) {
    animation-fill-mode: both;
    animation-timing-function: linear;
    animation-timeline: view();
    animation-range: entry 5% entry 42%;
  }

  .rise, .rise-2 { animation-name: vista-sale; }
  .rise-2, .fade { animation-range: entry 14% entry 55%; }
  .fade { animation-name: vista-fade; }
}

@keyframes vista-sale { from { opacity: 0; transform: translateY(28px); } }
@keyframes vista-fade { from { opacity: 0; } }

@keyframes sale { from { opacity: 0; transform: translateY(0.32em); } }

@media (hover: hover) and (pointer: fine) {
  .lift-hover {
    transition: translate 320ms var(--ease-spring), box-shadow 320ms var(--ease);
  }

  .lift-hover:hover { translate: 0 -0.4rem; box-shadow: var(--lift-high); }
}

/* --- Il campo miele con le onde (Hero del sito) -------------------------- */

.honey-field {
  position: relative;
  overflow: hidden;
  background: var(--honey);
  /* Risale sotto l'header sticky: il miele arriva fino in cima. */
  margin-top: -4.5rem;
}

.waves {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.waves .w1, .waves .w2, .waves .w3 { animation: onda 9s ease-in-out infinite alternate; }
.waves .w2 { animation-duration: 12.5s; animation-delay: -6s; --amp: -46px; --amp-y: 16px; }
.waves .w3 { animation-duration: 16s; animation-delay: -12s; --amp: 52px; --amp-y: -18px; }
.waves .base { fill: var(--honey); }

@keyframes onda {
  to { transform: translate(var(--amp, 38px), var(--amp-y, -12px)); }
}

/* --- Raccordo a onda tra superfici (WaveDivider del sito) ---------------- */

.wave {
  margin-top: -1px;
  line-height: 0;
  overflow: hidden;
}

.wave svg {
  display: block;
  width: 100%;
  height: clamp(3.25rem, 8vw, 6.5rem);
  overflow: visible;
}

.wave .ghost { opacity: 0.45; animation: acqua-viva 8s ease-in-out infinite alternate; }

.wave-honey path { fill: var(--honey); }
.wave-ink path { fill: var(--ink); }
.wave-bg path { fill: var(--bg); }
.wave.to-honey { background: var(--honey); }
.wave.to-ink { background: var(--ink); }

@supports (animation-timeline: view()) {
  .wave svg {
    animation: deriva both linear;
    animation-timeline: view();
    animation-range: cover 0% cover 100%;
  }
}

@keyframes deriva {
  from { transform: translateX(-48px); }
  to { transform: translateX(48px); }
}

@keyframes acqua-viva {
  from { transform: translateX(-22px); }
  to { transform: translateX(22px); }
}

/* --- Footer: sul campo miele, come la chiusura del sito ------------------ */

.footer {
  background: var(--honey);
  padding-block: clamp(2.25rem, 5vw, 3.25rem);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem 2rem;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

.footer-company {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--step-small);
  letter-spacing: var(--track-small);
  color: var(--on-honey-muted);
}

.footer-company img {
  height: 1.3rem;
  width: auto;
  filter: brightness(0); /* PNG ufficiale reso monocromo, come sul sito */
}

.footer-note {
  font-size: var(--step-small);
  color: var(--on-honey-muted);
  max-width: 46ch;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-links a {
  font-size: var(--step-small);
  color: var(--on-honey-muted);
  text-decoration: none;
  padding-block: 0.65rem;
  margin-block: -0.65rem;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Movimento ridotto: tutto allo stato finale --------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .rise, .rise-2, .fade, .em, .wave svg, .wave path, .waves path { animation: none; }
}
