/* Self-hosted Caveat (Latin) — no external request, no font-swap flash */
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/caveat-latin.woff2") format("woff2");
}

:root {
  --bg: #f6f6f4;
  --fg: #1a1a1a;
  --muted: #6c6c68; /* AA contrast (~4.7:1) on --bg */
  --line: #e6e6e2;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Inline arrow icons (project nav) */
.ico { display: inline-block; width: 13px; height: 13px; vertical-align: -2px; }
.ico-l { margin-right: 6px; }
.ico-r { margin-left: 6px; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

/* Keyboard focus — visible ring on all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #1b1bf5;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Reveal on load — a gentle fade-up ─────────────────── */
@keyframes revealUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.col, .doc, .nf-col { animation: revealUp 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.corner-time, .corner-dot { animation: fadeIn 0.7s ease 0.12s both; }

/* Visible keyboard focus (mouse clicks stay ring-free via :focus-visible) */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid #1b1bf5;
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Editorial column ──────────────────────────────────── */
.screen {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 76px 32px 72px;
}
.screen.home { padding-top: 120px; } /* home hero sits a little lower on desktop */
.col { width: 100%; max-width: 620px; }

/* Project title (case-study masthead) */
.intro { margin-bottom: 24px; }
.name {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.role { margin: 5px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); }

/* Lede statement — one accent weight, measured size */
.lede {
  margin: 0 0 16px;
  font-size: clamp(18px, 2vw, 21px);
  font-weight: 500;
  line-height: 1.42;
  letter-spacing: -0.012em;
  color: var(--fg);
  text-wrap: pretty;
}
.lede a,
.reach a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease;
}
.lede a:hover,
.reach a:hover { text-decoration-color: var(--fg); }

/* Reach-me line — UI text size + accent weight, underlined links */
.reach {
  margin: 46px 0 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--fg);
}

/* Footer meta */
.foot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 46px;
}
.scribble {
  display: inline-block;
  font-family: "Caveat", cursive;
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  color: #1b1bf5;
  transform: rotate(-3deg);
  transform-origin: left center;
  user-select: none;
}

/* ── Work — editorial index list ───────────────────────── */
.index-wrap { width: 100%; margin-top: 46px; }

.index-label { margin: 0 0 8px; font-size: 14px; line-height: 1.35; color: var(--muted); }
.index-wrap + .index-wrap { margin-top: 40px; }

.index { list-style: none; margin: 0; padding: 0; }

.index li a {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: baseline;
  gap: 20px;
  padding: 5px 0;
}
.index li.group { margin-top: 5px; }
.index li.group a { border-top: 1px solid var(--line); padding-top: 12px; }

.row-year { font-size: 14px; color: var(--muted); }
.row-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  transition: opacity 0.25s ease;
}
.index li a:hover .row-name { opacity: 0.5; }
.index li a.row-static { cursor: default; }
.index li a.row-static .row-name { color: var(--muted); }
.row-date { font-size: 14px; color: var(--muted); justify-self: end; }

/* ── Corner clock + drawing dot ─────────────────────────── */
.corner-time {
  position: absolute;
  top: 20px;
  left: 24px;
  z-index: 10;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--fg);
  user-select: none;
}
.corner-time span { color: var(--fg); font-variant-numeric: tabular-nums; }

.corner-dot {
  position: absolute;
  top: 22px;
  right: 24px;
  z-index: 10;
  width: 13px;
  height: 13px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #1b1bf5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.corner-dot:hover {
  transform: scale(1.25);
  background: #0f0fce;
  box-shadow: 0 0 0 5px rgba(27, 27, 245, 0.14);
}
.corner-dot:focus-visible { outline: none; box-shadow: 0 0 0 5px rgba(27, 27, 245, 0.2); }

body.paint-open { overflow: hidden; }

.paint {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #ffffff;
  transform-origin: 50% 100%;
  animation: paintIn 0.32s ease both;
}
.paint.closing { animation: paintOut 0.26s ease forwards; }
@keyframes paintIn {
  from { opacity: 0; transform: scale(0.992); }
  to { opacity: 1; transform: none; }
}
@keyframes paintOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.992); }
}
#paint-canvas {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* Opening flourish — inspiring words fade through the centre */
.paint-intro[hidden] { display: none; }
.paint-intro {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.paint-intro .intro-word {
  font-family: "Caveat", cursive;
  font-size: clamp(56px, 12vw, 132px);
  font-weight: 700;
  line-height: 1;
  color: #1b1bf5;
  animation: introWord 0.72s ease both;
}
.paint-intro .intro-word svg { width: clamp(56px, 12vw, 128px); height: auto; display: block; }
@keyframes introWord {
  0% { opacity: 0; transform: translateY(12px) scale(0.94); }
  22% { opacity: 1; transform: none; }
  74% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-10px) scale(1.03); }
}
@media (prefers-reduced-motion: reduce) {
  .paint-intro { display: none; }
}
/* One refined floating control bar */
.paint-bar {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 14px;
  background: rgba(18, 18, 20, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

/* Size control wrapper — transparent on desktop, its own row on mobile */
.size-ctl { display: contents; }

/* Live brush-size indicator + slider — fixed footprint so the bar never
   reflows; the dot scales via transform to show the current brush size */
.size-dot {
  display: block;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1b1bf5;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  transform: scale(0.44);
  transition: transform 0.12s ease, background 0.15s ease;
}
.paint-size {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 4px;
  margin: 0 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
}
.paint-size::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.paint-size::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.paint-divider { width: 1px; height: 20px; margin: 0 4px; background: rgba(255, 255, 255, 0.14); }

.paint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.paint-icon svg { width: 20px; height: 20px; }
.paint-icon:hover { background: rgba(255, 255, 255, 0.11); color: #fff; }
.paint-icon.active { background: #1b1bf5; color: #fff; }
.paint-icon.open { background: rgba(255, 255, 255, 0.14); color: #fff; }
.paint-icon:disabled { opacity: 0.3; cursor: default; }
.paint-icon:disabled:hover { background: transparent; color: rgba(255, 255, 255, 0.82); }

/* Brush button mirrors the active tool's tip */
#paint-brush svg { width: auto; height: 27px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4)); }

/* Brush-style picker popover */
.brush-menu[hidden] { display: none; }
.brush-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 8px;
  background: rgba(18, 18, 20, 0.86);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.5);
  z-index: 4;
  animation: menuIn 0.18s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.brush-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 52px;
  padding: 6px 4px 8px;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}
.brush-opt:hover { background: rgba(255, 255, 255, 0.06); }
.brush-opt.active { background: rgba(255, 255, 255, 0.12); }
.brush-preview {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 72px;
  overflow: visible;
}
.brush-preview svg {
  width: 30px;
  height: 72px;
  display: block;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35));
}
.brush-opt.active .brush-preview svg { transform: translateY(-9px); }
.brush-name {
  font-size: 10px;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.6);
}
.brush-opt.active .brush-name { color: #fff; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 720px) {
  .screen { padding: 84px 20px 56px; }
  .screen.home { padding-top: 84px; }
  .index li a { grid-template-columns: 52px 1fr auto; gap: 16px; padding: 9px 0; }

  /* Footer sits at the bottom of the screen, with room to breathe */
  .home .col { display: flex; flex-direction: column; min-height: calc(100svh - 140px); }
  .home .foot-meta { margin-top: auto; padding-top: 52px; }

  .corner-time { top: 16px; left: 20px; }
  .corner-dot { top: 18px; right: 20px; }

  /* Two rows: size control on top (full width), actions evenly spaced below */
  .paint-bar {
    bottom: calc(20px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    row-gap: 8px;
    padding: 10px 16px;
    width: calc(100vw - 20px);
    max-width: 440px;
    border-radius: 999px;
  }
  .size-ctl {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 100%;
    padding: 2px 4px 4px;
  }
  .paint-size { flex: 1 1 auto; width: auto; min-width: 0; height: 5px; }
  .paint-size::-webkit-slider-thumb { width: 20px; height: 20px; }
  .paint-size::-moz-range-thumb { width: 20px; height: 20px; }
  .paint-divider { display: none; }
  .paint-icon { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
