/* ==========================================================================
   Como Vamos? Padel Score — "How to Use" page
   Layer order: fonts → reset/base → header → footer → labels → steps → responsive
   ========================================================================== */

/* Fonts (self-hosted, SIL OFL 1.1) ---------------------------------------- */
@font-face {
  font-family: "Jersey 10";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/jersey-10-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Jersey 10";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/jersey-10-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Jersey 15";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/jersey-15-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Jersey 15";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/jersey-15-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

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

body {
  margin: 0;
  overflow-x: hidden;
  /* `clip` keeps the body from becoming a scroll container (which breaks
     position: sticky in Safari); `hidden` is the fallback for older browsers. */
  overflow-x: clip;
  background-color: var(--bg);
  /* Static dot grid — replaced by the canvas only when JS upgrades it. */
  background-image: radial-gradient(
    circle,
    var(--dot) calc(var(--dot-size) / 2),
    transparent calc(var(--dot-size) / 2)
  );
  background-size: var(--dot-pitch) var(--dot-pitch);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  /* Header / content / footer rows: the footer stays at the bottom of the
     viewport on short pages (404) and follows the content on long ones. The
     rows are assigned explicitly below so a page without a header (404) still
     gives the spare space to the content instead of stretching the footer. */
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

body > .header {
  grid-row: 1;
}

body > .main {
  grid-row: 2;
}

body > .footer {
  grid-row: 3;
}

/* Grid items default to min-width:auto, which lets wide content (for example a
   text-sized plate at a large type size) widen the whole page instead of
   wrapping inside it. */
body > .header,
body > .main,
body > .footer {
  min-width: 0;
}

body.dots-canvas {
  background-image: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--surface);
  color: var(--ink);
  border: var(--label-border) solid var(--line);
  padding: 8px 16px;
  font-size: var(--fs-body);
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* Canvas layer (added by js/dot-grid.js) ---------------------------------- */
#dot-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Page shell -------------------------------------------------------------- */
.page {
  position: relative;
  z-index: 1;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header ------------------------------------------------------------------ */
.header {
  position: relative;
  z-index: 1;
  /* min-height, not height: at larger user text sizes the plate grows and the
     header grows with it instead of the plate spilling over the main content. */
  min-height: var(--header-height);
  /* Padding (not the plate's margin) holds the plate down, so the plate
     margin cannot collapse out of the header and shift the page. */
  padding-top: var(--plate-offset-y);
}

/* The header is anchored to the viewport's left edge on every width (as in the
   desktop Penpot board), while the article column below stays centred. */
.header__inner {
  position: relative;
  padding-left: calc(var(--gutter) + var(--plate-offset-x)); /* 25px */
}

/* Pink diagonal hatch: a fixed band anchored to the left edge, not a
   full-bleed background. It stops short of the plate's right edge, so the
   plate overhangs it exactly like in the design. */
.header::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: min(var(--hatch-width), calc(100% - var(--gutter)));
  height: var(--hatch-height);
  z-index: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--brand) 0 var(--stripe-width),
    transparent var(--stripe-width) var(--stripe-period)
  );
}

/* Hand-drawn card surface: the header plate and the footer card are the same
   object at different scales — white fill, ink border, hard offset shadow.
   Each card supplies its own border width and shadow through custom props. */
.brand,
.footer__card {
  background: var(--surface);
  border: var(--card-border) solid var(--line);
  box-shadow: var(--card-shadow);
}

.brand {
  --card-border: var(--plate-border);
  --card-shadow: var(--plate-shadow);
  position: relative;
  width: min(var(--plate-width), calc(100% - var(--gutter)));
  margin: 0;
  /* The plate has no fixed height: 16px vertical padding + the name/tagline
     block size it, so it grows with the text instead of clipping or
     overflowing a hard-coded 104px box. */
  padding: var(--plate-padding-y) var(--plate-inset-x);
  display: flex;
  align-items: center;
  gap: var(--plate-gap);
  container-type: inline-size;
}

.brand__logo {
  width: 64px;
  height: 64px;
  flex: none;
  /* The design clips the square artwork to a circle and draws a 1px ring. */
  border-radius: 50%;
  outline: 4px solid var(--ink);
  outline-offset: 0px;
}

.brand__text {
  min-width: 0;
}

.brand__name {
  margin: 0;
  font-family: var(--font-display);
  /* 48px at the 389px plate width (12.34cqw), scaling with the plate. */
  font-size: clamp(1.75rem, 12.34cqw, var(--fs-wordmark));
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0;
}

.brand__tagline {
  margin: 2px 0 0;
  font-family: var(--font-sub);
  font-size: clamp(1.125rem, 7.71cqw, var(--fs-subtitle));
  font-weight: 400;
  line-height: 1;
}

/* From 35em (560px at the default root size) the plate is sized by its text
   instead of the 389px design width: the longer tagline then stays on one line
   at its full 30px size. Below this the plate is still capped by the viewport,
   so the type keeps scaling down and the tagline wraps (the one-line layout
   needs a ~483px plate, ~499px in Spanish). The breakpoint is in em so it
   follows the user's default font size. */
@media (min-width: 35em) {
  .brand {
    container-type: normal;
    width: max-content;
    max-width: calc(100% - var(--gutter));
  }

  .brand__name {
    font-size: var(--fs-wordmark);
  }

  .brand__tagline {
    font-size: var(--fs-subtitle);
  }
}

/* Language switcher ------------------------------------------------------- */
/* Anchored to the header (not the plate), so it stays pinned to the window's
   right edge with the design's 14px / 16px insets on mobile and desktop. */
.lang-switch {
  position: absolute;
  top: var(--lang-inset-top);
  right: var(--gutter);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--lang-gap);
}

.lang-switch__link {
  display: block;
  width: var(--lang-flag-size);
  height: var(--lang-flag-size);
  border-radius: 50%;
  line-height: 0;
}

/* The selected language carries the design's 4px black outer stroke. A spread
   box shadow draws it outside the 26px disc, so the row never changes size. */
.lang-switch__link[aria-current="true"] {
  box-shadow: 0 0 0 var(--lang-ring) var(--line);
}

.lang-switch__flag {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.lang-switch__link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

/* Footer ------------------------------------------------------------------ */
/* The footer is a full-bleed layer like the header: on mobile it spans the
   viewport minus 24px gutters; from 768px up it hugs the right edge, 24px in.
   Penpot: "Footer" 392×78 (mobile) / auto×78 (desktop), "Footer Smaller"
   275×126 stacked below 440px. Shadow included in the 24px offsets. */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  padding: 0 var(--footer-offset) var(--footer-offset);
}

.footer__card {
  --card-border: var(--footer-border);
  --card-shadow: var(--footer-shadow);
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  width: 100%;
  padding: var(--footer-padding);
}

/* Credit + social links keep their own column; the card's row layout places
   the Ko-fi button and this block side by side. */
.footer__info {
  display: flex;
  flex-direction: column;
  gap: var(--footer-gap);
  width: fit-content;
  /* Let the credit block shrink and reflow when enlarged text would otherwise
     make the horizontal card wider than the viewport. */
  min-width: 0;
  flex: 0 1 auto;
}

/* Ko-fi slot: the widget writes its own button markup in place
   (document.writeln), so this only aligns the slot and styles the fallback. */
.footer__kofi {
  display: flex;
  align-items: center;
  flex: none;
}

.footer__kofi-fallback {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 7px;
  background: var(--kofi-color);
  /* White on #72a4f2 is only 2.53:1; the ink token gives 5.98:1. */
  color: var(--ink);
  font-family: "Quicksand", Helvetica, "Trebuchet MS", sans-serif;
  font-size: 0.875rem; /* 14px */
  font-weight: 700;
  line-height: 2.5714; /* the design's 36px at 14px, scaled with the text */
  text-decoration: none;
}

.footer__kofi-fallback[hidden] {
  display: none;
}

/* Third-party Ko-fi widget: its injected style paints the label #fff on the
   configured #72a4f2 (2.5:1). Recolour only the label with a stronger selector
   and drop the text shadow; the brand background is unchanged (ink = 5.98:1). */
.footer__kofi .kofitext {
  color: var(--ink) !important;
  text-shadow: none !important;
}

/* The widget also forces the cup to 22 × 15 although the source is 285 × 229
   (1.24), which stretches it. Let the width follow the intrinsic ratio at the
   15px height instead. */
.footer__kofi .kofitext img.kofiimg {
  width: auto !important;
  height: 15px !important;
}

.footer__kofi-fallback:hover {
  opacity: 0.85;
}

.footer__kofi-fallback:focus-visible {
  outline: var(--label-border) solid var(--ink);
  outline-offset: 3px;
}

.footer__kofi a.kofi-button {
  border: var(--label-border) solid var(--line) !important;
  border-radius: 0;
}

.footer__made,
.footer__links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--footer-gap);
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-footer);
  font-weight: 400;
  line-height: var(--lh-footer);
  color: var(--ink);
}

.footer__links {
  gap: var(--footer-link-gap);
}

.footer__icon {
  flex: none;
}

.footer__icon--heart {
  width: var(--footer-icon-size);
  height: var(--footer-icon-size);
}

.footer__icon--whale {
  width: 21.363892px;
  height: 15.71875px;
}

.footer__rule {
  width: 100%;
  margin: 0;
  border: 0;
  border-top: var(--footer-rule) solid var(--line);
}

/* Instagram / LinkedIn use the Penpot tokens retro.text.link and
   retro.text.link-hover (see --link / --link-hover). */
.footer__link {
  color: var(--link);
  text-decoration: none;
}

.footer__link:hover,
.footer__link:focus-visible {
  color: var(--link-hover);
}

.footer__link:focus-visible {
  outline: var(--label-border) solid var(--ink);
  outline-offset: 3px;
}

/* Desktop: the card sizes to its content (button + 24px + credit) and sits
   against the right gutter, mirroring the header's left anchor. */
@media (min-width: 768px) {
  .footer {
    justify-content: flex-end;
  }

  .footer__card {
    width: fit-content;
    gap: var(--footer-column-gap);
    justify-content: center;
  }
}

/* Narrow phones: the horizontal card needs ~440px, so switch to the stacked
   "Footer Smaller" layout below that. */
@media (max-width: 439px) {
  .footer__card {
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: var(--footer-small-gap);
  }
}

/* Keep the Ko-fi cup wiggle out of reduced-motion mode (the widget injects
   its animation with a lower-specificity !important rule). */
@media (prefers-reduced-motion: reduce) {
  .footer .footer__kofi img.kofiimg {
    animation: none !important;
  }
}

/* Wide screens: pin the full-bleed header and footer while the centred 440px
   column scrolls between them. From 560px the plate is text-sized (483px in
   English, 499px in Spanish); the widest shadow ends at x = 540, while the
   content text starts at (W − 440) / 2 + 16. Sticky therefore needs ~1489px of
   layout width; 1510px also leaves room for a classic scrollbar. The footer
   card (starting at W − 438.6) clears from 1318px. Below 1510px both keep
   scrolling with the page. */
@media (min-width: 1510px) {
  /* Both wrappers span the viewport but are visually empty outside the plate,
     hatch, language switcher and card: let clicks reach the content that
     scrolls behind them, and re-enable interaction on the real controls. */
  .header,
  .footer {
    position: sticky;
    z-index: 2;
    pointer-events: none;
  }

  .header {
    top: 0;
  }

  .footer {
    bottom: 0; /* the 24px visual gap comes from the footer's padding */
  }

  .brand,
  .lang-switch,
  .footer__card {
    pointer-events: auto;
  }

  /* The skip link targets #main; with the header pinned, leave room above the
     target so the first content is not hidden underneath the header. */
  .main {
    scroll-margin-top: calc(var(--header-height) + 16px);
  }
}

/* Content ----------------------------------------------------------------- */
.main {
  padding-top: 50px;
  padding-bottom: 96px;
}

/* Hand-drawn label boxes (design: 2px/3px black border + hard offset shadow) */
.label {
  /* flex, not inline-flex: an inline-level box would add a line box and push
     the figure below it down by ~16px. */
  display: flex;
  align-items: center;
  width: fit-content;
  /* min-height keeps the design's 52px box at default type, but lets the box
     grow instead of clipping the label when the user's text size is larger. */
  min-height: var(--label-height);
  margin: 0;
  padding: 0 var(--label-inset);
  border: var(--label-border) solid var(--line);
  background: var(--surface);
  box-shadow: var(--label-shadow);
  transform: rotate(var(--label-rotation));
  font-family: var(--font-display);
  font-size: var(--fs-label);
  font-weight: 400;
  line-height: 1;
}

.label--wide {
  display: flex;
  justify-content: center;
  width: 100%;
  /* The wide "How to Use" bar carries a deeper shadow in the design. */
  box-shadow: var(--label-shadow-wide);
}

/* Store CTA: Penpot board 408 × 52 above the "How to Use" bar ------------- */
.store-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  min-height: var(--label-height);
  padding: 0 16px;
  background: var(--cta-bg);
  border: var(--label-border) solid var(--line);
  box-shadow: var(--label-shadow-wide);
  color: var(--line);
  font-family: var(--font-display);
  font-size: var(--fs-label);
  line-height: 1;
  text-align: center;
  text-decoration: none;
}

/* Hover/focus background is the design system's retro.bg.highlight (sun). */
.store-cta:hover,
.store-cta:focus-visible {
  background: var(--cta-bg-hover);
}

.store-cta:focus-visible {
  outline: var(--label-border) solid var(--ink);
  outline-offset: 4px;
}

.store-cta__icon {
  width: 24px;
  height: 24px;
  flex: none;
}

/* 42px between the CTA and the "How to Use" bar, matching the design rhythm. */
.store-cta + .label--wide {
  margin-top: var(--intro-gap);
}

/* Steps ------------------------------------------------------------------- */
.step {
  margin-top: var(--step-gap);
}

.label--wide + .step {
  margin-top: var(--intro-gap);
}

.step__figure {
  margin: 0;
  display: grid;
  place-items: center;
}

/* The <picture> wrapper only supplies format negotiation; it must not take part
   in layout (the keys figure positions its image absolutely). */
.step__figure picture {
  display: contents;
}

.step__figure img {
  width: 400px;
  height: auto;
}

/* Keys figure: the design places the key names around the watch as separate
   text nodes. Geometry is expressed in em against the 30px key font so the
   whole group scales down on narrow screens without breaking the layout.
   Design coords (408×344 board): image 56,0 295×344; Up 21,150; Down 28,256;
   Back 337,260; Enter 342,46. */
.step__figure--keys {
  position: relative;
  width: 13.6em; /* 408 / 30 */
  height: 11.4667em; /* 344 / 30 */
  margin: 16px auto 0;
  font-size: min(30px, calc((100vw - 32px) / 13.6));
}

.step__figure--keys img {
  position: absolute;
  left: 1.8667em; /* 56 / 30 */
  top: 0;
  width: 9.8333em; /* 295 / 30 */
  height: 11.4667em;
}

.key {
  position: absolute;
  font-size: 1em;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}

.key--up {
  left: 0.7em;
  top: 5em;
}

.key--down {
  left: 0.9333em;
  top: 8.5333em;
}

.key--back {
  left: 11.2333em;
  top: 8.6667em;
}

.key--enter {
  left: 11.4em;
  top: 1.5333em;
}

.step__text {
  margin: 0;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  white-space: pre-line;
}

/* Wide screens: the desktop board keeps the 440px column, so only the
   full-bleed layers change. Widen --page-width if the design adds one. */
@media (min-width: 1024px) {
  .main {
    padding-bottom: 140px;
  }
}

/* Reduced motion is handled by js/dot-grid.js (it never starts). The static
   label rotation is a design property, not an animation, so it stays. */

/* Links that reuse the brand/label components ------------------------------ */
.brand--link {
  text-decoration: none;
  color: inherit;
}

.brand--link:focus-visible {
  outline: var(--label-border) solid var(--ink);
  outline-offset: 4px;
}

.label--link {
  text-decoration: none;
  color: var(--ink);
}

.label--link:hover,
.label--link:focus-visible {
  background: var(--line);
  color: var(--surface);
}

.label--link:focus-visible {
  outline: var(--label-border) solid var(--ink);
  outline-offset: 4px;
}

/* 404 page ---------------------------------------------------------------- */
.not-found .step__text {
  margin-top: 32px;
  max-width: var(--content-width);
}

.not-found__title {
  max-width: var(--content-width);
}

.not-found__actions {
  margin: 40px 0 0;
}
