/* ---------------------------------------------------------------
   Shared styles. Visual idea: a drawer of paper gift tags.

   Motion rules:
   - One orchestrated moment on load (tags get dealt onto the page).
   - Everything else responds to YOU: hover, focus, click.
   - Nothing loops, nothing floats, nothing pulses on its own.
   - All of it dies under prefers-reduced-motion.
   --------------------------------------------------------------- */

:root {
  --ink:      #2B2118;   /* pencil on kraft */
  --paper:    #FAF6F0;   /* page */
  --kraft:    #E8DCC8;   /* tag stock */
  --kraft-2:  #D9C9AE;   /* tag edge */
  --ribbon:   #A83C52;   /* the one loud colour */
  --ribbon-d: #8E3145;
  --twine:    #B9A681;
  --muted:    #6E6154;

  --measure: 34rem;
  --gap: clamp(2.5rem, 6vw, 5rem);

  /* one easing curve everywhere: slight overshoot, like paper settling */
  --settle: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: Karla, ui-sans-serif, system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  position: relative;
}

/* paper grain — fixed, behind everything, barely there */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

body > * { position: relative; z-index: 1; }

/* ---- layout ---------------------------------------------------- */

.wrap { width: min(68rem, 100% - 2.5rem); margin-inline: auto; }
.narrow { max-width: var(--measure); }

main { padding-block: var(--gap) calc(var(--gap) * 1.4); }
section + section { margin-top: var(--gap); }

/* ---- type ------------------------------------------------------ */

h1, h2, h3 {
  font-family: Fraunces, Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.4rem, 6.5vw, 4.1rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); margin-top: 1.6em; }
h3 { font-size: 1.25rem; margin-top: 2em; }

p { margin: 0 0 1.1em; max-width: var(--measure); }

.lede { font-size: 1.2rem; color: var(--muted); max-width: 32rem; }

/* ---- links ----------------------------------------------------- */
/* underline sweeps out from the left instead of just appearing */

a { color: var(--ribbon); }

main a:not(.buy) {
  text-decoration: none;
  background-image: linear-gradient(var(--ribbon), var(--ribbon));
  background-size: 0% 1.5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 260ms var(--settle);
  padding-bottom: 1px;
}
main a:not(.buy):hover,
main a:not(.buy):focus-visible { background-size: 100% 1.5px; }

/* tags handle their own hover, so opt them out of the underline sweep */
.tag a, .tag a:hover, .tag a:focus-visible { background-image: none; padding-bottom: 0; }

:focus-visible { outline: 2.5px solid var(--ribbon); outline-offset: 3px; border-radius: 2px; }

/* ---- masthead -------------------------------------------------- */

.masthead {
  padding-block: 1.6rem;
  border-bottom: 1px solid var(--kraft-2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  align-items: baseline;
  justify-content: space-between;
}

/* the wordmark grows on hover — scale, not font-size, so it stays smooth */
.wordmark {
  font-family: Fraunces, Georgia, serif;
  font-variation-settings: "SOFT" 60, "WONK" 1;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: inline-block;
  transform-origin: left center;
  transition:
    transform 320ms var(--settle),
    font-variation-settings 320ms ease,
    color 200ms ease;
}
.wordmark:hover,
.wordmark:focus-visible {
  transform: scale(1.11);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  color: var(--ribbon);
}
.wordmark:active { transform: scale(1.04); }

.masthead nav { display: flex; gap: 1.3rem; font-size: 0.95rem; }
.masthead nav a {
  color: var(--muted);
  text-decoration: none;
  position: relative;
  padding-bottom: 2px;
  transition: color 180ms ease;
}
.masthead nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  height: 1.5px; width: 100%;
  background: var(--ribbon);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 280ms var(--settle);
}
.masthead nav a:hover { color: var(--ink); }
.masthead nav a:hover::after,
.masthead nav a:focus-visible::after { transform: scaleX(1); }

/* ---- footer ---------------------------------------------------- */

.colophon {
  border-top: 1px solid var(--kraft-2);
  padding-block: 2.2rem 3rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.colophon p { max-width: 40rem; margin-bottom: 0.6em; }
.colophon a { color: var(--muted); transition: color 180ms ease; }
.colophon a:hover { color: var(--ribbon); }

/* ---- the tag --------------------------------------------------- */

.tags {
  list-style: none;
  padding: 0;
  margin: 2.5rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 1.4rem;
}

.tag { position: relative; }

/* twine loop through the punched hole */
.tag::before {
  content: "";
  position: absolute;
  top: -0.35rem;
  left: 0.45rem;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--twine);
  border-radius: 50%;
  border-right-color: transparent;
  border-top-color: transparent;
  transform: rotate(-38deg);
  transform-origin: 50% 90%;
  transition: transform 420ms var(--settle);
  pointer-events: none;
  z-index: 2;
}
.tag:hover::before { transform: rotate(-29deg); }

.tag a {
  display: block;
  min-height: 9.5rem;
  padding: 1.15rem 1.3rem 1.3rem 2.6rem;
  background-color: var(--kraft);
  border: 1px solid var(--kraft-2);
  color: var(--ink);
  text-decoration: none;
  clip-path: polygon(0 1.6rem, 1.6rem 0, 100% 0, 100% 100%, 0 100%);
  transform-origin: 12% 4%;   /* pivots near the hole, like it's hanging */
  will-change: transform;
  transition:
    transform 380ms var(--settle),
    background-color 240ms ease,
    box-shadow 380ms var(--settle);
}

/* the tag lifts and tilts, as if picked up by the string */
.tag a:hover,
.tag a:focus-visible {
  background-color: #F1E8D8;
  transform: translateY(-5px) rotate(-1.4deg);
  box-shadow: -3px 10px 22px -8px rgba(43, 33, 24, 0.28);
}
.tag a:active { transform: translateY(-1px) rotate(-0.5deg); }

/* punched hole */
.tag a::before {
  content: "";
  position: absolute;
  top: 0.95rem;
  left: 0.95rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--kraft-2);
  z-index: 1;
}

.tag .for {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.tag .who {
  font-family: Fraunces, Georgia, serif;
  font-variation-settings: "SOFT" 50, "WONK" 1;
  font-weight: 600;
  font-size: 1.22rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  display: block;
}

.tag .count {
  position: absolute;
  bottom: 1.1rem;
  left: 2.6rem;
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 240ms ease;
}
.tag a:hover .count { color: var(--ribbon); }

/* ---- the one orchestrated moment: dealing the tags out ---------- */

@keyframes deal {
  from { opacity: 0; transform: translateY(14px) rotate(-2.5deg); }
  to   { opacity: 1; transform: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.hero h1    { animation: rise 620ms var(--settle) both; }
.hero .lede { animation: rise 620ms var(--settle) 110ms both; }

.tags .tag { animation: deal 560ms var(--settle) both; }
.tags .tag:nth-child(1) { animation-delay: 200ms; }
.tags .tag:nth-child(2) { animation-delay: 265ms; }
.tags .tag:nth-child(3) { animation-delay: 330ms; }
.tags .tag:nth-child(4) { animation-delay: 395ms; }
.tags .tag:nth-child(5) { animation-delay: 460ms; }
.tags .tag:nth-child(6) { animation-delay: 525ms; }
.tags .tag:nth-child(n+7) { animation-delay: 590ms; }

/* ---- hero ------------------------------------------------------ */

.hero { padding-block: clamp(3rem, 8vw, 5.5rem) 0; }
.hero h1 { max-width: 16ch; }

/* ---- disclosure strip ------------------------------------------ */

.disclosure {
  border-left: 3px solid var(--ribbon);
  padding: 0.1rem 0 0.1rem 1rem;
  margin: 0 0 2.2rem;
  font-size: 0.94rem;
  color: var(--muted);
}
.disclosure p { margin-bottom: 0; }

/* ---- picks ------------------------------------------------------ */

.pick {
  border-top: 1px solid var(--kraft-2);
  padding-top: 1.6rem;
  margin-top: 2.2rem;
}
.pick h3 { margin-top: 0; transition: color 200ms ease; }
.pick:hover h3 { color: var(--ribbon); }
.pick .why { color: var(--muted); }

/* button: lifts, label opens up slightly, presses back down on click */
.buy {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.65rem 1.2rem;
  background-color: var(--ribbon);
  color: var(--paper);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 2px;
  transition:
    background-color 200ms ease,
    transform 220ms var(--settle),
    box-shadow 220ms var(--settle),
    letter-spacing 220ms var(--settle);
}
.buy:hover, .buy:focus-visible {
  background-color: var(--ribbon-d);
  color: var(--paper);
  transform: translateY(-2px);
  letter-spacing: 0.012em;
  box-shadow: 0 6px 16px -6px rgba(168, 60, 82, 0.55);
}
.buy:active { transform: translateY(0); box-shadow: none; }

/* ---- legal pages ------------------------------------------------ */

.legal { max-width: 42rem; }
.legal h2 { font-size: 1.35rem; margin-top: 2.2em; }
.legal p, .legal li { font-size: 1rem; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin-bottom: 0.4em; }

/* ---- respect the setting ---------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
  .tag a:hover, .tag a:focus-visible { transform: none; }
  .wordmark:hover, .wordmark:focus-visible { transform: none; }
  .buy:hover, .buy:focus-visible { transform: none; letter-spacing: normal; }
}
