/* =============================================================================
   OpiDesigns — "The Colophon"
   A fine-art-catalogue title spread. Three colours, two faces, one motif:
   the terracotta dot. Cream is paper; espresso is every readable mark;
   terracotta is rationed to the dot and its echoes (bullets, glaze, focus).
   The static page is the canonical version — motion is pure enhancement.
   ============================================================================= */

/* ---- Fonts (self-hosted, latin subset) ---------------------------------- */
@font-face {
  font-family: "Comfortaa";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/comfortaa-500.woff2") format("woff2");
}
@font-face {
  font-family: "Comfortaa";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/comfortaa-700.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/source-serif-4-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/source-serif-4-400-italic.woff2") format("woff2");
}

/* ---- Tokens ------------------------------------------------------------- */
:root {
  --cream: #f7f0e8;
  --terra: #c0522a;
  --ink: #2c1f1a;

  --rule: rgba(44, 31, 26, 0.16);
  --hairline: rgba(44, 31, 26, 0.13);
  --tint: rgba(44, 31, 26, 0.035);
  --tint-strong: rgba(44, 31, 26, 0.06);
  --press: rgba(44, 31, 26, 0.12);

  --measure: 33rem;
  --radius: 22px;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --brand: "Comfortaa", ui-rounded, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

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

html {
  background-color: var(--cream);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh; /* fallback for engines without svh support */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1rem, 0.96rem + 0.3vw, 1.125rem);
  line-height: 1.65;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Quiet paper grain — sits behind all text, never animated. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='160'%20height='160'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.8'%20numOctaves='2'%20stitchTiles='stitch'/%3E%3CfeColorMatrix%20type='saturate'%20values='0'/%3E%3C/filter%3E%3Crect%20width='100%25'%20height='100%25'%20filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Layout ------------------------------------------------------------- */
main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding: clamp(3.5rem, 10vh, 7rem) clamp(1.5rem, 6vw, 2.5rem) 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.05rem;
}

.block {
  width: 100%;
  margin-top: clamp(3rem, 9vh, 5.25rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ---- The mark ----------------------------------------------------------- */
.mark {
  width: clamp(84px, 16vw, 112px);
  height: auto;
  display: block;
  overflow: visible; /* room for the dot's entrance */
}

/* ---- Typography --------------------------------------------------------- */
.wordmark {
  margin: 0.35rem 0 0;
  font-family: var(--brand);
  font-weight: 700;
  font-size: clamp(1.05rem, 0.9rem + 1.1vw, 1.5rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-indent: 0.22em; /* recentre the tracked caps */
  color: var(--ink);
}

.subtitle {
  margin: 0;
  max-width: 26rem;
  font-style: italic;
  font-size: clamp(1.08rem, 1rem + 0.55vw, 1.32rem);
  line-height: 1.5;
  color: var(--ink);
  opacity: 0.85;
}

.rule {
  width: min(60px, 18vw);
  height: 0;
  margin: clamp(1.75rem, 6vh, 3rem) 0 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  font-family: var(--brand);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
}
/* the terracotta dot, reprised as a bullet */
.label::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--terra);
  flex: none;
}

.lede {
  margin: 0;
  max-width: 30rem;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.2rem);
  line-height: 1.7;
}

/* ---- Destination tiles (the funnel) ------------------------------------ */
.tiles {
  width: 100%;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tile {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  width: 100%;
  padding: 1.15rem 1.3rem;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  background: var(--tint);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.tile__stamp {
  flex: none;
  width: 36px;
  height: 36px;
  display: block;
}

.tile__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.tile__label {
  font-family: var(--brand);
  font-weight: 700;
  font-size: 1.06rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.tile__desc {
  font-family: var(--serif);
  font-size: 0.96rem;
  line-height: 1.4;
  color: var(--ink);
  opacity: 0.72;
}

.tile__sub {
  font-family: var(--brand);
  font-weight: 500;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0.72; /* keeps espresso-on-tint above WCAG AA (4.5:1) */
}

.tile__arrow {
  flex: none;
  align-self: flex-start;
  margin-top: 0.15rem;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink);
  opacity: 0.5;
}

/* the glaze: a terracotta hairline that traces the tile on hover/focus.
   Sized precisely by main.js; invisible (and harmless) if JS never runs. */
.tile__glaze {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}
.tile__glaze rect {
  stroke: var(--terra);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---- Mailto ------------------------------------------------------------- */
.mailto {
  color: var(--ink);
  font-style: italic;
  text-decoration: underline;
  text-decoration-color: rgba(192, 82, 42, 0.5);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  white-space: nowrap;
}

/* ---- Colophon ----------------------------------------------------------- */
.colophon {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: clamp(3rem, 8vh, 5rem) 1.5rem clamp(2rem, 5vh, 3rem);
}
.colophon__mark {
  width: 30px;
  height: 30px;
  display: block;
}
.colophon__word {
  font-family: var(--brand);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.colophon__fine {
  font-family: var(--serif);
  font-size: 0.8rem;
  color: var(--ink);
  opacity: 0.72; /* keeps espresso-on-cream above WCAG AA (4.5:1) */
}

/* ---- Focus -------------------------------------------------------------- */
a:focus-visible,
.tile:focus-visible {
  outline: 3px solid var(--terra);
  outline-offset: 3px;
  border-radius: 6px;
}
.tile:focus-visible {
  outline-offset: 4px;
  border-radius: var(--radius);
}

/* =============================================================================
   Motion — strictly opt-in. Hover/press transitions and the once-per-session
   entrance run only when the user has no reduced-motion preference.
   ============================================================================= */
@media (prefers-reduced-motion: no-preference) {
  /* Hover / focus / press */
  .tile {
    transition: transform 0.22s ease, background-color 0.3s ease, border-color 0.3s ease,
      box-shadow 0.22s ease;
  }
  .tile__stamp { transition: transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1); }
  .tile__arrow { transition: transform 0.3s ease, opacity 0.3s ease; }
  .tile__glaze rect { transition: stroke-dashoffset 0.65s cubic-bezier(0.65, 0, 0.35, 1); }
  .mailto { transition: text-decoration-color 0.3s ease; }

  @media (hover: hover) {
    .tile:hover { background: var(--tint-strong); }
    .tile:hover .tile__stamp { transform: scale(1.09) rotate(-4deg); }
    .tile:hover .tile__arrow { transform: translate(3px, -3px); opacity: 0.85; }
    .tile:hover .tile__glaze rect { stroke-dashoffset: 0; }
    .mailto:hover { text-decoration-color: var(--terra); }
  }

  .tile:focus-visible .tile__glaze rect { stroke-dashoffset: 0; }
  .tile:focus-visible .tile__arrow { transform: translate(3px, -3px); opacity: 0.85; }
  .mailto:focus-visible { text-decoration-color: var(--terra); }

  /* ---- Entrance (html.anim, once per session) ---- */
  html.anim .reveal {
    opacity: 0;
    animation: fadeUp 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    animation-delay: var(--d, 0s);
  }
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
  }

  html.anim .wordmark { --d: 0.55s; }
  html.anim .subtitle { --d: 0.72s; }
  html.anim .rule { --d: 0.92s; }
  html.anim main > section:nth-of-type(1) { --d: 0.4s; }
  html.anim main > section:nth-of-type(2) { --d: 0.52s; }
  html.anim main > section:nth-of-type(3) { --d: 0.64s; }
  html.anim .colophon { --d: 0.76s; }

  /* The mark draws itself: ring strokes in, then the dot falls into its seat. */
  html.anim .mark__ring {
    stroke-dasharray: 365;
    stroke-dashoffset: 365;
    animation: ringDraw 1.15s cubic-bezier(0.65, 0, 0.35, 1) 0.15s forwards;
  }
  @keyframes ringDraw { to { stroke-dashoffset: 0; } }

  html.anim .mark__dot {
    transform-box: fill-box;
    transform-origin: center;
    animation: dotFall 0.85s cubic-bezier(0.34, 1.25, 0.64, 1) 0.6s both;
  }
  @keyframes dotFall {
    0% { transform: translateY(-150px); opacity: 0; }
    40% { opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
  }
}

/* Press: applies regardless of motion preference (instant when reduced). */
.tile:active {
  transform: translateY(2px);
  background: var(--tint-strong);
  box-shadow: inset 0 2px 7px var(--press);
}

/* Without hover (touch): tap shows the glaze + a warm tint so tiles read pressable. */
@media (hover: none) {
  .tile:active .tile__glaze rect { stroke-dashoffset: 0; }
  .tile:active .tile__stamp { transform: scale(1.06); }
}

/* Reduced motion: hard stop on all animation/transition as a final safety net. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .tile:hover .tile__glaze rect,
  .tile:focus-visible .tile__glaze rect { stroke-dashoffset: 0; }
  .tile:hover { background: var(--tint-strong); }
  .mailto:hover,
  .mailto:focus-visible { text-decoration-color: var(--terra); }
}
