/* Shared styles for every page on arlenamarie.com.
   Per-page differences (background, orbit speed, wiggle size, glow color)
   are CSS custom properties. Pages set --page-bg in their own <style>;
   site.js sets the orbit and title variables from each page's config. */

/* ── Fonts (self-hosted, Latin subset from Google Fonts, SIL OFL 1.1) ──
   Licences: /assets/fonts/OFL-Caveat.txt and OFL-CaveatBrush.txt.
   Every page preloads both files from its <head>; keep those paths in sync.
   Caveat is a variable font, so one file covers weights 400 to 700. */
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/caveat-latin.woff2) format('woff2');
}

@font-face {
  font-family: 'Caveat Brush';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/caveat-brush-latin.woff2) format('woff2');
}

/* ── Palette ── */
:root {
  --cream: #f5f1e8;
  --ink: #1a1209;
  --star-1: #f4b6c2;
  --star-2: #b8e0d2;
  --star-3: #d4c5e8;
  --star-4: #f5d985;
  --star-5: #f5a896;
  --star-6: #a8d8ea;
  --page-bg: var(--cream);
}

/* ── Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--page-bg);
}

body { font-family: 'Caveat', cursive; }

/* <picture> only picks WebP or the PNG fallback; it adds no box of its own,
   so the <img> lays out exactly as if it were unwrapped */
picture { display: contents; }

/* <main> marks the page content for assistive tech without adding a box,
   so each page's own body layout (flex centering) applies as before */
main { display: contents; }

/* ── Wiggle title ──
   Letters are built by Site.title(). Each page sets --wiggle-rot, --wiggle-lift
   and --wiggle-spd on the title element. Add .glow to the title for the
   pulsing text-shadow (colors in --glow and --glow-faint). */
.wiggle-letter {
  display: inline-block;
  animation: wiggle var(--wiggle-spd, 2.4s) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}

.glow .wiggle-letter {
  animation:
    wiggle var(--wiggle-spd, 3s) ease-in-out infinite,
    glow var(--wiggle-spd, 3s) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}

@keyframes wiggle {
  0%, 100% { transform: rotate(calc(var(--wiggle-rot, 5deg) * -1)) translateY(0); }
  50%      { transform: rotate(var(--wiggle-rot, 5deg)) translateY(calc(var(--wiggle-lift, 4px) * -1)); }
}

@keyframes glow {
  0%, 100% {
    text-shadow:
      0 0 6px var(--glow),
      0 0 12px var(--glow),
      0 0 18px var(--glow);
  }
  50% {
    text-shadow:
      0 0 12px var(--glow),
      0 0 24px var(--glow),
      0 0 40px var(--glow),
      0 0 60px var(--glow-faint);
  }
}

/* ── Orbit ──
   Markup: .orbit-anchor > .orbit-ring > .orbit-item (items added by Site.orbit()).
   The ring spins and each item counter-spins so it stays upright.
   site.js sets --orbit-position, --orbit-z and --orbit-duration per page. */
.orbit-anchor {
  position: var(--orbit-position, fixed);
  top: 50%;
  left: 50%;
  z-index: var(--orbit-z, 1);
  pointer-events: none;
}

.orbit-ring { animation: orbit-spin var(--orbit-duration, 50s) linear infinite; }

.orbit-item {
  position: absolute;
  animation: orbit-unspin var(--orbit-duration, 50s) linear infinite;
}

@keyframes orbit-spin { to { transform: rotate(360deg); } }
@keyframes orbit-unspin { to { transform: rotate(-360deg); } }

/* ── World orbit (homepage, GSAP) ──
   Markup: .orbit-world > .orbit-slot > .orbit-star (added by Site.worldOrbit()).
   Each slot covers .world, so translate(%) on it is a percent of .world. */
.orbit-world {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.orbit-slot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orbit-star svg { display: block; }

/* Letters animated by GSAP get no keyframe wiggle */
[data-motion="gsap"] .wiggle-letter { animation: none; }

/* ── Intro: starting state until the GSAP timeline animates it ──
   html.intro is set in the page <head> (skipped for reduced motion) and
   removed by site.js if GSAP does not arrive within 3 s.
   Stars and letters start hidden. Tiles start visible at half size, so
   they paint on first render (this is what keeps LCP fast). */
.intro .orbit-star,
.intro [data-motion="gsap"] .wiggle-letter { opacity: 0; }
.intro .tile-body { scale: 0.5; }

/* ── Nav tiles (homepage) ──
   .tile owns position (translate) and hover (scale via --s). GSAP transforms only
   the inner .tile-body, because GSAP folds an element's translate/scale
   properties into its own transform and would freeze -50% as pixels. */
.tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  z-index: 5;
  --s: 1;       /* hover scale, tweened by Site.hover() */
  --swap: 0;    /* 0 = idle icon, 1 = hover icon and label dropped 2 px */
  scale: var(--s);
}

/* Until gsap loads (or if it never does): same end states, no tween */
html:not(.motion) .tile:hover { --s: 1.12; --swap: 1; }

.tile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tile-img {
  position: relative;
  width: clamp(60px, 14vmin, 140px);
  height: clamp(60px, 14vmin, 140px);
}

.tile-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-img .idle  { opacity: calc(1 - var(--swap)); }
.tile-img .hover { opacity: var(--swap); }

.tile-label {
  margin-top: 4px;
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: clamp(11px, 2.2vmin, 20px);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  translate: 0 calc(var(--swap) * 2px);
}

/* Hex positions (% of the .world square) */
.tile.pos-t  { top: 1%;  left: 50%; translate: -50% 0; }             /* top center */
.tile.pos-lu { top: 22%; left: 2%; }                                  /* left upper */
.tile.pos-ru { top: 22%; right: 2%; }                                 /* right upper */
.tile.pos-ll { top: 52%; left: 2%; }                                  /* left lower */
.tile.pos-rl { top: 52%; right: 2%; }                                 /* right lower */
.tile.pos-b  { bottom: 0%; left: 50%; translate: -50% 0; }          /* bottom center */

@media (max-width: 480px) {
  .tile-img {
    width: clamp(50px, 18vw, 90px);
    height: clamp(50px, 18vw, 90px);
  }
}

/* ── Back link (fixed, bottom center) ── */
.back-link {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Caveat', cursive;
  font-size: clamp(16px, 3vmin, 20px);
  color: var(--ink);
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 0.2s;
  z-index: 30;
}

.back-link:hover { opacity: 1; }

/* ── Page transitions: native cross-document view transition ──
   Same-origin links cross-fade in 0.35 s. Browsers without support just
   navigate instantly. Off for reduced motion, which drops transitions only;
   orbits, wiggles and hover keep running on every page. */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.35s; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
