/* Gair Design holding page.
   One centred column. Every size is fluid (clamp/min against the viewport's width AND height),
   so the composition scales as one piece on any screen with no breakpoints, no sideways scroll
   and no visible edges around the logo. */

/* Fonts are self-hosted (no third-party requests). Both are Open Font License. */
@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda-latin.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("fonts/jost-latin.woff2") format("woff2");
  font-weight: 300 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #141414;
  --ivory: #F5F0E6;
  --ivory-muted: rgba(245, 240, 230, 0.55);
  --copper: #B87333;
  --serif: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --sans: "Jost", "Futura", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Screen height, with fallbacks for older browsers */
  --vh: 100vh;
  /* Logo: 72% of the width on phones, capped at 520px, and shrunk on short screens
     so the whole column always fits (1.83 is the logo's width-to-height ratio). */
  --logo-w: clamp(140px, min(72vw, (var(--vh) - 320px) * 1.83), 520px);
  --carton-w: clamp(64px, 6vw, 96px);
  --gap-logo: clamp(20px, 3vh, 32px);
  --gap-motto: clamp(28px, 4.5vh, 44px);
  --gap-close: clamp(14px, 2vh, 20px);
  --gutter: 24px;
  color-scheme: dark;
}
@supports (height: 100svh) {
  :root { --vh: 100svh; }
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ivory);
  font-family: var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

main {
  min-height: var(--vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding:
    max(var(--gutter), env(safe-area-inset-top, 0px))
    max(var(--gutter), env(safe-area-inset-right, 0px))
    max(var(--gutter), env(safe-area-inset-bottom, 0px))
    max(var(--gutter), env(safe-area-inset-left, 0px));
}

h1 { margin: 0; line-height: 0; }
.logo {
  display: block;
  width: var(--logo-w);
  max-width: 100%;
  height: auto;
}

.carton {
  display: block;
  width: var(--carton-w);
  height: auto;
  margin-top: var(--gap-logo);
  overflow: visible;
}

.motto {
  margin: var(--gap-motto) 0 0;
  font-family: var(--serif);
  font-style: normal;
  font-weight: 400;
  font-variation-settings: "opsz" 96; /* hairline display cut, matching the logo */
  font-size: clamp(22px, 1.6vw + 12px, 34px);
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--ivory);
  max-width: 100%;
  text-wrap: balance;
}

.closing {
  margin: var(--gap-close) 0 0;
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(10px, 0.3vw + 9px, 12px);
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  /* letter-spacing adds space after the last letter; pull it back so the line is truly centred */
  margin-right: -0.32em;
  color: var(--ivory-muted);
}

/* Carton line art */
.carton * { vector-effect: non-scaling-stroke; }
.cut  { fill: none; stroke: var(--copper); stroke-width: 1; stroke-linejoin: round; stroke-linecap: round; }
.fold { fill: none; stroke: var(--copper); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.85; }
.carton g { transform-box: view-box; }
.shift  { transform: translateX(-12px); }
.side-l { transform-origin: 30px 0; }
.side-r { transform-origin: 50px 0; }
.back   { transform-origin: 60px 0; }
.glue   { transform-origin: 80px 0; }
.lid-t  { transform-origin: 0 20px; }
.lid-b  { transform-origin: 0 48px; }
.closed { opacity: 0; }

/* Entrance */
.in { opacity: 0; animation: fade 1200ms var(--ease) both; }
.logo.in    { animation-delay: 200ms; }
.carton.in  { animation-duration: 800ms; animation-delay: 1200ms; }
.motto.in   { animation-name: rise; animation-duration: 900ms; animation-delay: 1800ms; }
.closing.in { animation-name: rise; animation-duration: 900ms; animation-delay: 2100ms; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 7 s fold loop, starting once the carton has appeared */
.loop .shift, .loop .side-l, .loop .side-r, .loop .back, .loop .glue,
.loop .lid-t, .loop .lid-b, .loop .front, .loop .closed {
  animation-duration: 7s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-delay: 2000ms;
  animation-fill-mode: both;
}
.loop .shift  { animation-name: shift; }
.loop .glue   { animation-name: glue; }
.loop .back   { animation-name: back; }
.loop .side-l, .loop .side-r { animation-name: sides; }
.loop .lid-t, .loop .lid-b   { animation-name: lids; }
.loop .front  { animation-name: front; }
.loop .closed { animation-name: closed; }

@keyframes shift  { 0%, 14% { transform: translateX(-12px); } 39%, 74% { transform: translateX(0); } 92%, 100% { transform: translateX(-12px); } }
@keyframes glue   { 0%, 14% { transform: scaleX(1); } 21%, 85% { transform: scaleX(0); } 92%, 100% { transform: scaleX(1); } }
@keyframes back   { 0%, 18% { transform: scaleX(1); } 27%, 80% { transform: scaleX(0); } 88%, 100% { transform: scaleX(1); } }
@keyframes sides  { 0%, 23% { transform: scaleX(1); } 33%, 74% { transform: scaleX(0); } 82%, 100% { transform: scaleX(1); } }
@keyframes lids   { 0%, 29% { transform: scaleY(1); } 39%, 68% { transform: scaleY(0); } 76%, 100% { transform: scaleY(1); } }
@keyframes front  { 0%, 40% { opacity: 1; } 43%, 64% { opacity: 0; } 67%, 100% { opacity: 1; } }
@keyframes closed { 0%, 41% { opacity: 0; } 45%, 63% { opacity: 1; } 66%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .in, .motto.in, .closing.in { animation: none; opacity: 1; transform: none; }
  .loop * { animation: none !important; }
  .closed { opacity: 0; }
}
