/* ============================================
   Ayla — Diciotto anni
   Archivio fotografico: verde profondo, avorio, oro solo in filetti.
   ============================================ */
:root {
  --ground: #11291c;          /* verde profondo, fondo */
  --surface: #173423;         /* superficie foto in attesa */
  --ink: #efe9dc;             /* avorio, testo principale */
  --ink-soft: #a9b8a6;        /* secondario, tinto di verde */
  --gold: #c9a55a;            /* oro: filetti, numerali, hover */
  --gold-dim: rgba(201, 165, 90, 0.42);
  --veil: rgba(11, 27, 18, 0.9);

  --font-display: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, "Helvetica Neue", sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: 14px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--ground);
  scrollbar-color: var(--gold-dim) var(--ground);
}

html.lightbox-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border: 3px solid var(--ground); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

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

/* ============ Filetti ============ */

.rule {
  display: inline-block;
  height: 1px;
  width: 40px;
  background: var(--gold-dim);
  vertical-align: middle;
}

.rule--short { width: 32px; display: block; margin: 0 auto 22px; }
.masthead .rule--short { margin-bottom: 24px; }

/* ============ Testata ============ */

.masthead {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(96px, 16vh, 168px) 24px clamp(56px, 8vh, 88px);
  text-align: center;
}

.name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0 0 26px;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(4rem, 12vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.name-occasion {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--gold);
}

.lede {
  margin: 0 auto 28px;
  max-width: 52ch;
  font-size: clamp(1.02rem, 1.4vw, 1.15rem);
  line-height: 1.5;
  color: var(--ink);
  text-wrap: balance;
}

.link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--gold-dim);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color 0.25s var(--ease-out), text-decoration-color 0.25s var(--ease-out);
}

.link:hover, .link:focus-visible { color: var(--gold); text-decoration-color: var(--gold); }

.meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold);
}

/* ============ Galleria: masonry a colonne ============ */

.gallery {
  --cols: 2;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--gutter) 120px;
  display: flex;
  gap: var(--gutter);
  align-items: flex-start;
}

@media (min-width: 720px)  { :root { --gutter: 20px; } .gallery { --cols: 3; } }
@media (min-width: 1100px) { .gallery { --cols: 4; } }
@media (min-width: 1600px) { .gallery { --cols: 5; } }

.gallery-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

.gallery-status {
  width: 100%;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  padding: 48px 0;
}

.photo {
  position: relative;
  margin: 0;
  background: var(--surface);
  opacity: 0;
  translate: 0 14px;
  animation: settle 0.9s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes settle {
  to { opacity: 1; translate: 0 0; }
}

.photo::after {
  /* filetto oro: appare solo al passaggio, non è mai un bordo fisso */
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--gold);
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
  pointer-events: none;
}

.photo:hover::after,
.photo:focus-within::after { opacity: 1; }

.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  color: inherit;
  font: inherit;
}

.photo-open img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface);
  transition: opacity 0.35s var(--ease-out);
}

.photo:hover img,
.photo:focus-within img { opacity: 0.92; }

/* il segno: già scaricata */
.mark {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--ground);
  opacity: 0;
  scale: 0.4;
  transition: opacity 0.3s var(--ease-out), scale 0.45s var(--ease-out);
  pointer-events: none;
}

.photo.is-taken .mark { opacity: 1; scale: 1; }

/* ============ Controlli: cerchio a filetto ============ */

.ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--gold-dim);
  border-radius: 50%;
  background: rgba(17, 41, 28, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color 0.25s var(--ease-out), color 0.25s var(--ease-out), background 0.25s var(--ease-out);
}

.ctrl:hover,
.ctrl:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
}

.ctrl:active { background: rgba(17, 41, 28, 0.9); }

.ctrl svg { display: block; flex: none; }

.ctrl--text {
  width: auto;
  height: 42px;
  padding: 0 20px 0 16px;
  border-radius: 999px;
}

.photo-download {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  opacity: 0;
  translate: 0 4px;
  transition: opacity 0.25s var(--ease-out), translate 0.3s var(--ease-out), border-color 0.25s, color 0.25s;
}

.photo:hover .photo-download,
.photo:focus-within .photo-download,
.photo-download:focus-visible {
  opacity: 1;
  translate: 0 0;
}

/* Senza mouse il bottone resta visibile, discreto. */
@media (hover: none) {
  .photo-download { opacity: 0.85; translate: 0 0; }
}

/* ============ Chiusura ============ */

.colophon {
  text-align: center;
  padding: 0 24px 88px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.colophon p { margin: 0 auto; max-width: 42ch; }

/* ============ Lightbox ============ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--veil);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity 0.25s var(--ease-out);
}

.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }

.lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 16px 104px;
  touch-action: pan-y;
  cursor: zoom-out;
}

@media (min-width: 720px) { .lightbox-stage { padding: 80px 96px 112px; } }

.lightbox-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out);
  transform: scale(0.985);
  opacity: 0;
}

.lightbox.is-open .lightbox-figure { transform: scale(1); opacity: 1; }
.lightbox-figure.is-dragging { transition: none; cursor: grabbing; }

.lightbox-img {
  display: block;
  max-width: calc(100vw - 32px);
  max-height: calc(100svh - 72px - 104px);
  width: auto;
  height: auto;
  object-fit: contain;
  background: var(--surface);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  transition: opacity 0.25s;
}

@media (min-width: 720px) {
  .lightbox-img {
    max-width: calc(100vw - 192px);
    max-height: calc(100svh - 80px - 112px);
  }
}

.lightbox.is-loading .lightbox-img { opacity: 0.5; }

.slide-from-right { animation: cross-right 0.5s var(--ease-out); }
.slide-from-left  { animation: cross-left 0.5s var(--ease-out); }

@keyframes cross-right {
  from { transform: translateX(28px); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}
@keyframes cross-left {
  from { transform: translateX(-28px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.lightbox-close { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 20px; }
.lightbox-prev  { position: absolute; left: 24px;  top: 50%; translate: 0 -50%; }
.lightbox-next  { position: absolute; right: 24px; top: 50%; translate: 0 -50%; }

/* Con il dito si scorre: le frecce laterali lasciano spazio alla foto. */
@media (hover: none) and (max-width: 719px) {
  .lightbox-prev, .lightbox-next { display: none; }
}

.lightbox-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}

.lightbox-bar > * { pointer-events: auto; }

.lightbox-count {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

/* ============ Movimento ridotto ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .photo { opacity: 1; translate: 0 0; }
}
