/* Layout and components for mafiabears.fr. Tokens live in tokens.css. */

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

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.55;
  font-optical-sizing: auto;
}

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

a { color: inherit; text-underline-offset: 0.18em; }

:focus-visible {
  outline: 3px solid var(--honey);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 0.5rem 1rem;
  background: var(--honey);
  color: var(--ink);
  font-weight: 700;
  z-index: 10;
}
.skip-link:focus { top: 0.75rem; }

/* ------------------------------------------------------------------ header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem var(--gutter);
}

.wordmark {
  font-weight: 700;
  font-stretch: var(--display-width);
  font-size: var(--step-1);
  line-height: 1;
  text-decoration: none;
}

/* Honey = commissions, everywhere on the site. */
.header-cta,
.site-footer__cta {
  display: inline-block;
  padding: 0.6rem 1rem;
  background: var(--honey);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}
.header-cta:hover,
.site-footer__cta:hover { background: var(--paper); }

/* ------------------------------------------------------------------ frame */

/* Every painting sits in a black ink outline, like a comic panel. */
.frame {
  position: relative;
  border: var(--frame) solid var(--ink);
  background: var(--ink);
}

/* Hero: the outline is traced once on load, edge after edge, like a pen going
   round the canvas. Four solid strips (top, right, bottom, left) grow in turn. */
.frame--draw { border-color: transparent; }

.frame--draw::after {
  content: "";
  position: absolute;
  inset: calc(var(--frame) * -1);
  pointer-events: none;
  background:
    linear-gradient(var(--ink), var(--ink)) left top / 100% var(--frame) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right top / var(--frame) 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) right bottom / 100% var(--frame) no-repeat,
    linear-gradient(var(--ink), var(--ink)) left bottom / var(--frame) 100% no-repeat;
  animation: trace-ink 1.6s cubic-bezier(0.45, 0, 0.55, 1) 0.3s backwards;
}

@keyframes trace-ink {
  0%   { background-size: 0 var(--frame), var(--frame) 0, 0 var(--frame), var(--frame) 0; }
  25%  { background-size: 100% var(--frame), var(--frame) 0, 0 var(--frame), var(--frame) 0; }
  50%  { background-size: 100% var(--frame), var(--frame) 100%, 0 var(--frame), var(--frame) 0; }
  75%  { background-size: 100% var(--frame), var(--frame) 100%, 100% var(--frame), var(--frame) 0; }
  100% { background-size: 100% var(--frame), var(--frame) 100%, 100% var(--frame), var(--frame) 100%; }
}

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

.hero {
  background: var(--scene);
  color: var(--on-scene);
  padding: clamp(1rem, 3vw, 2.5rem) var(--gutter) var(--scene-pad);
}

.hero__piece { margin: 0; }

.hero__caption {
  margin-top: 0.9rem;
  font-size: var(--step--1);
  max-width: var(--measure);
}
.hero__caption-title { font-weight: 700; }

.hero__text {
  display: grid;
  gap: 1rem 3rem;
  margin-top: clamp(2.5rem, 7vw, 6rem);
}

.hero__text h1 {
  margin: 0;
  font-size: var(--step-3);
  font-weight: 800;
  font-stretch: var(--display-width);
  line-height: 0.82;
  letter-spacing: -0.02em;
}

.hero__lede {
  margin: 0;
  max-width: 22ch;
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.25;
}

@media (min-width: 900px) {
  .hero__text {
    grid-template-columns: auto 1fr;
    align-items: end;
  }
  .hero__lede { padding-bottom: 0.6em; }
}

/* ------------------------------------------------------------------ scenes */

.scene {
  background: var(--scene);
  color: var(--on-scene);
  padding: var(--scene-pad) var(--gutter);
}

/* A painting is never taller than 82% of the screen: its width is capped from its
   own ratio (set by build.py), so the whole canvas is visible at once. */
.piece {
  margin: 0 auto;
  max-width: min(860px, calc(82svh * var(--ratio, 1)));
}
.scene--wide .piece { max-width: min(1160px, calc(82svh * var(--ratio, 1))); }

.caption { max-width: var(--measure); }

.caption__title {
  margin: 1.75rem 0 0.6rem;
  font-size: var(--step-2);
  font-weight: 800;
  font-stretch: var(--display-width);
  line-height: 0.95;
  letter-spacing: -0.01em;
}

.caption__meta,
.caption__note { margin: 0; }
.caption__meta { font-weight: 600; }

/* Tall canvases are taller than the screen: the image scrolls past while the
   caption stays in view beside it. */
@media (min-width: 900px) {
  .scene--tall .piece {
    display: grid;
    grid-template-columns: minmax(0, 34vw) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 5rem);
    align-items: start;
    max-width: 1160px;
  }
  .scene--tall .caption {
    position: sticky;
    top: 35vh;
  }
  .scene--tall .caption__title { margin-top: 0; }
}

@media (max-width: 899px) {
  .scene--tall .frame { max-width: 80vw; margin-inline: auto; }
}

/* ------------------------------------------------------------------ drawings strip */

/* Drawings run edge to edge in one row: the section keeps its vertical padding
   but the strip itself is full-bleed, aligned on the page gutter by
   scroll-padding so the first drawing starts where the titles start. */
.scene--strip { padding-inline: 0; }

.strip-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: end;
  padding-inline: var(--gutter);
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}
.strip-head .caption__title { margin-top: 0; }

.strip-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.strip-controls[hidden] { display: none; }

.strip-controls__btn {
  width: 3rem;
  height: 3rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}
.strip-controls__btn:hover { background: var(--honey); }
.strip-controls__btn:disabled { opacity: 0.3; cursor: default; background: var(--paper); }
.strip-controls__count { min-width: 4.5ch; text-align: center; }

.strip {
  display: flex;
  gap: clamp(1rem, 2.5vw, 2rem);
  margin: 0;
  padding: 0 var(--gutter) 1.25rem;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-color: var(--ink) transparent;
}
.strip:focus-visible { outline-offset: -3px; }

.strip__item {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

/* Same height for every drawing; width follows each drawing's own ratio. */
.strip__item img {
  width: auto;
  height: min(62svh, 560px);
}

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

.site-footer {
  padding: clamp(3.5rem, 8vw, 7rem) var(--gutter) 2rem;
}

.site-footer__ask {
  margin: 0 0 1.5rem;
  max-width: 24ch;
  font-size: var(--step-2);
  font-weight: 800;
  font-stretch: var(--display-width);
  line-height: 0.95;
}

.site-footer__legal {
  margin: clamp(3rem, 8vw, 6rem) 0 0;
  font-size: var(--step--1);
  color: var(--muted-on-ink);
}

/* ------------------------------------------------------------------ contact */

.contact {
  background: var(--honey);
  color: var(--ink);
  padding: clamp(3rem, 8vw, 7rem) var(--gutter) var(--scene-pad);
}

.contact__inner { max-width: 36rem; }

.contact h1 {
  margin: 0 0 1rem;
  font-size: var(--step-2);
  font-weight: 800;
  font-stretch: var(--display-width);
  line-height: 0.95;
}

.contact__intro { margin: 0 0 2.5rem; max-width: var(--measure); }

.contact :focus-visible { outline-color: var(--ink); }

.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.field__hint {
  display: block;
  font-weight: 400;
  font-size: var(--step--1);
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
.field textarea { min-height: 10rem; resize: vertical; }

.button {
  padding: 0.85rem 1.4rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--paper); color: var(--ink); }
.button[disabled] { cursor: progress; opacity: 0.7; }

.form-status {
  min-height: 1.6em;
  margin: 1.25rem 0 0;
  font-weight: 700;
}

/* ------------------------------------------------------------------ motion */

@media (prefers-reduced-motion: reduce) {
  .frame--draw::after { animation: none; }
}
