/* Optional age confirmation, loaded on every page when the producer turns it on. The dialog covers the whole
   viewport itself instead of relying on ::backdrop, which older browsers do not let inherit the theme. Themes
   restyle it through the --age-gate-* properties; the buttons are the theme's own. */
:root {
  --age-gate-backdrop: #1d1a17;
  --age-gate-paper: #fbf8f2;
  --age-gate-ink: #1d1a17;
  --age-gate-line: rgb(29 26 23 / .55);
  --age-gate-liquid: #e3a03a;
  --age-gate-foam: #fffaf0;
  --age-gate-water: #a9d8ea;
  --age-gate-ease-out: cubic-bezier(.23, 1, .32, 1);
  --age-gate-ease-in-out: cubic-bezier(.77, 0, .175, 1);
  /* easeOutBack from easings.net: the head of foam overshoots the rim a little, then settles. */
  --age-gate-ease-back: cubic-bezier(.34, 1.56, .64, 1);
}
/* Before the dialog opens, the same colour covers the page, so nothing flashes behind it. */
html.age-gate-pending::before { content: ''; position: fixed; inset: 0; z-index: 2147483647; background: var(--age-gate-backdrop); }
html:is(.age-gate-pending, .age-gate-open) { overflow: hidden; }

.age-gate {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 16px; border: 0;
  background: var(--age-gate-backdrop); color: var(--age-gate-ink); overflow-y: auto; overscroll-behavior: contain;
}
.age-gate[open] { display: grid; place-items: center; }
.age-gate::backdrop { background: transparent; }
.age-gate.is-leaving { opacity: 0; transition: opacity .44s var(--age-gate-ease-out); }

.age-gate-card {
  box-sizing: border-box; width: min(100%, 30rem); padding: clamp(28px, 7vw, 48px) clamp(20px, 6vw, 44px);
  background: var(--age-gate-paper); text-align: center; overflow-wrap: anywhere;
  animation: age-gate-in .5s var(--age-gate-ease-out) both;
}
/* The card only holds the first focus for screen readers; the id outranks theme focus rings. */
#age-gate .age-gate-card:focus { outline: none; }
.age-gate-card > * { animation: age-gate-in .5s var(--age-gate-ease-out) both; }
.age-gate-card > :nth-child(2) { animation-delay: .06s; }
.age-gate-card > :nth-child(3) { animation-delay: .1s; }
.age-gate-card > :nth-child(4) { animation-delay: .14s; }
.age-gate-card > :nth-child(n + 5) { animation-delay: .18s; }
.age-gate:is(.is-leaving, .is-handing-off) .age-gate-card { opacity: 0; scale: .97; transition: opacity .32s var(--age-gate-ease-out), scale .32s var(--age-gate-ease-out); }

.age-gate-eyebrow { margin: 18px 0 8px; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; }
.age-gate h2 { margin: 0 0 14px; font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.05; text-wrap: balance; }
.age-gate p { margin: 0 auto; max-width: 36ch; line-height: 1.6; }
.age-gate-message { margin-top: 12px !important; font-size: .9rem; opacity: .8; }
.age-gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 28px; }
.age-gate-actions .button { flex: 1 1 10rem; max-width: 14rem; justify-content: center; cursor: pointer; font: inherit; }
.age-gate-refusal span { display: block; margin-top: 20px; font-size: .95rem; animation: age-gate-in .4s var(--age-gate-ease-out) both; }
.age-gate-refusal span[hidden] { display: none; }

/* The glass. Liquid rises from the bottom; beer gets a head, everything gets bubbles. */
.age-gate-glass { display: block; width: 92px; height: auto; margin: 0 auto; overflow: visible; transform-origin: 50% 100%; }
.age-gate-outline { fill: none; stroke: var(--age-gate-line); stroke-width: 3; stroke-linejoin: round; }
.age-gate-shine { fill: none; stroke: var(--age-gate-line); stroke-width: 3; stroke-linecap: round; opacity: .35; }
.age-gate-liquid {
  fill: var(--age-gate-liquid); transform-box: fill-box; transform-origin: 50% 100%; scale: 1 0;
  transition: scale .75s var(--age-gate-ease-in-out), fill .5s ease;
}
.age-gate-foam {
  fill: var(--age-gate-foam); opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; scale: .8; translate: 0 22px;
  transition: opacity .2s ease, scale .42s var(--age-gate-ease-back), translate .42s var(--age-gate-ease-back);
}
.age-gate-bubbles { opacity: 0; transition: opacity .3s ease; }
.age-gate-bubbles circle { --rise: -112px; fill: var(--age-gate-foam); animation: age-gate-rise 1.5s linear infinite paused; }
.age-gate-bubbles circle:nth-child(2) { animation-delay: -.3s; }
.age-gate-bubbles circle:nth-child(3) { animation-delay: -.7s; }
.age-gate-bubbles circle:nth-child(4) { animation-delay: -1s; }
.age-gate-bubbles circle:nth-child(5) { animation-delay: -1.25s; }

/* Pointing at an answer tips in a splash of what it would pour. */
@media (hover: hover) and (pointer: fine) {
  .age-gate:not([data-state]):has([data-age-gate="yes"]:hover) .age-gate-liquid { scale: 1 .14; }
  .age-gate:not([data-state]):has([data-age-gate="no"]:hover) .age-gate-liquid { scale: 1 .14; fill: var(--age-gate-water); }
}
.age-gate:not([data-state]):has([data-age-gate="yes"]:focus-visible) .age-gate-liquid { scale: 1 .14; }
.age-gate:not([data-state]):has([data-age-gate="no"]:focus-visible) .age-gate-liquid { scale: 1 .14; fill: var(--age-gate-water); }

.age-gate[data-state] .age-gate-bubbles { opacity: .75; transition-delay: .3s; }
.age-gate[data-state] .age-gate-bubbles circle { animation-play-state: running; }
.age-gate[data-state="refused"] .age-gate-bubbles circle { --rise: -78px; }
.age-gate[data-state="refused"] .age-gate-liquid { scale: 1 .72; fill: var(--age-gate-water); }
/* A yes after a no turns the water into the real thing on the way up. */
.age-gate[data-state="confirmed"] .age-gate-liquid { scale: 1 1; }
.age-gate[data-kind="brewery"][data-state="confirmed"] .age-gate-foam { opacity: 1; scale: 1; translate: 0 0; transition-delay: .5s; }
.age-gate[data-state="confirmed"] .age-gate-glass { animation: age-gate-cheers .42s var(--age-gate-ease-in-out) .95s; }

/* Wine and spirits pour their own colour, without a head. */
.age-gate[data-kind="winery"] { --age-gate-liquid: #8a1f2f; }
.age-gate[data-kind="distillery"] { --age-gate-liquid: #c98b2e; }

@keyframes age-gate-in { from { opacity: 0; translate: 0 14px; scale: .97; } }
@keyframes age-gate-rise { 0% { translate: 0 0; opacity: 1; } 75% { opacity: 1; } 100% { translate: 0 var(--rise); opacity: 0; } }
@keyframes age-gate-cheers { 40% { rotate: -9deg; } 75% { rotate: 3deg; } }

@media (prefers-reduced-motion: reduce) {
  .age-gate-card, .age-gate-card > *, .age-gate-refusal span { animation-name: age-gate-fade; }
  .age-gate:is(.is-leaving, .is-handing-off) .age-gate-card { scale: 1; }
  .age-gate-liquid, .age-gate-foam { transition-property: opacity, fill; }
  .age-gate-foam { scale: 1; translate: 0 0; }
  .age-gate-bubbles circle { animation: none; }
  .age-gate[data-state] .age-gate-bubbles { opacity: 0; }
  .age-gate[data-state="confirmed"] .age-gate-glass { animation: none; }
}
@keyframes age-gate-fade { from { opacity: 0; } }

/* Valduc-Thor, on its theme's slate: the intro's background, a yellow-ruled card and an amber pour under the bar light. */
[data-theme="affiche"][data-producer-id="valduc"] {
  --age-gate-backdrop: var(--slate), radial-gradient(ellipse 60% 70% at 50% 120%, #3d2814, transparent 70%), #151515;
  --age-gate-paper: var(--grain), radial-gradient(ellipse 70% 45% at 50% 0%, rgb(243 154 43 / .16), transparent 70%), #1f1f1f;
  --age-gate-ink: #fff; --age-gate-line: rgb(255 255 255 / .8);
  --age-gate-liquid: var(--glow); --age-gate-foam: #fff8e6; --age-gate-water: #9fd3e6;
  .age-gate-card { border-top: 3px solid var(--sun); box-shadow: 0 30px 80px rgb(0 0 0 / .55); }
  .age-gate-eyebrow { display: inline-flex; align-items: center; gap: 12px; color: var(--sun); font: 400 .78rem/1.3 var(--text); letter-spacing: .16em; }
  .age-gate-eyebrow::before { content: ''; flex: none; width: 7px; height: 7px; background: var(--red); rotate: 45deg; }
  .age-gate h2 { font-size: clamp(2.3rem, 9vw, 3.4rem); line-height: 1; }
  .age-gate p:not(.age-gate-eyebrow) { color: #dedbd5; }
  .age-gate-message { padding-top: 14px; background: var(--ornament) 50% 0 / 132px 12px no-repeat; }
  .age-gate-glass { width: 104px; filter: drop-shadow(0 10px 24px rgb(243 154 43 / .22)); }
}
