/* ---------- Fonts (self-hosted, free) ---------- */
@font-face { font-family: "Pirata One"; font-weight: 400; font-display: swap; src: url(fonts/pirata-one-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Space Mono"; font-weight: 400; font-display: swap; src: url(fonts/space-mono-latin-400-normal.woff2) format("woff2"); }

/* ---------- Colors & type ---------- */
:root {
  --bg: #050505;
  --text: #e9e3d3;
  --muted: #98948d;
  --grain: 0.12;

  /* photo count + info lines */
  --meta-font: "Space Mono", ui-monospace, monospace;
  --meta-size: 11px;
  --meta-case: uppercase;

  /* wordmark + @ (the color roulette overrides --mark-color on hover) */
  --mark-font: "Pirata One", serif;
  --mark-size: 46px;
  --mark-case: none;
  --mark-color: #e5195f;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

html {
  background-color: var(--bg);
}

/* Fine film grain on the background only, never on the photos */
body::before {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.6 -0.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.8s steps(4) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3%, 2%); }
  50%  { transform: translate(2%, -4%); }
  75%  { transform: translate(-2%, -1%); }
  100% { transform: translate(3%, 3%); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

body {
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

main {
  min-height: 100%;
  display: grid;
  place-items: center;
  /* clears the corner labels; app.js fits the photo into what's left */
  padding: 84px 28px 28px;
}

/* ---------- Edge labels ---------- */
.edge {
  position: fixed;
  font: 11px/1 "Space Mono", ui-monospace, monospace;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  z-index: 1;
}
.wordmark {
  top: 24px; left: 28px;
  font-family: var(--mark-font);
  font-size: var(--mark-size);
  text-transform: var(--mark-case);
  color: var(--mark-color);
  line-height: 0.9;
  letter-spacing: 0;
}

/* @ in the bottom-right corner: emails Jay, same color as the wordmark */
.contact {
  bottom: 22px; right: 28px;
  font-family: var(--mark-font);
  font-size: calc(var(--mark-size) * 0.65);
  color: var(--mark-color);
  line-height: 1;
}

/* ---------- Photo ---------- */
figure { width: fit-content; }

figure header {
  /* width:0 + min-width:100% = follow the photo's width, never widen it */
  width: 0;
  min-width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

/* Count: top-right of the photo, opposite the info at bottom-left */
.count {
  font-family: var(--meta-font);
  font-size: var(--meta-size);
  line-height: 1.6;
  color: var(--muted);
  white-space: nowrap;
}

/* Photo info sits under the photo, left edge */
figure footer {
  width: 0;
  min-width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-top: 14px;
}

.meta {
  font-family: var(--meta-font);
  font-size: var(--meta-size);
  text-transform: var(--meta-case);
  line-height: 1.6;
  color: var(--muted);
  white-space: nowrap;
}

.meta span { display: block; }

button { all: unset; cursor: pointer; }
button:focus-visible { outline: 1px solid var(--muted); outline-offset: 6px; }

.photo { display: block; }

.photo img {
  display: block;
  max-width: calc(100vw - 56px);
  max-height: calc(100vh - 300px); /* fallback; app.js sets the real size */
  width: auto;
  height: auto;
  transition: opacity 0.25s ease;
}

.loading .photo img { opacity: 0; }

/* ---------- Broken smiley after the wordmark ---------- */
.smiley {
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.18em;
  vertical-align: 0.02em;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.smiley .dot { fill: currentColor; stroke: none; }

.wordmark.glitch .smiley {
  filter: drop-shadow(2px 0 rgba(255, 0, 76, 0.8)) drop-shadow(-2px 0 rgba(0, 229, 255, 0.8));
}

/* ---------- Wordmark glitch (while the color roulette spins) ---------- */
.wordmark.glitch {
  animation: wm-jitter 0.16s steps(2) infinite;
  text-shadow: 2px 0 rgba(255, 0, 76, 0.8), -2px 0 rgba(0, 229, 255, 0.8);
}

/* two torn copies of the word, sliced into bands and shoved sideways */
.wordmark.glitch::before,
.wordmark.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
}
.wordmark.glitch::before {
  text-shadow: -3px 0 #00e5ff;
  animation: wm-slice-a 0.24s steps(1) infinite;
}
.wordmark.glitch::after {
  text-shadow: 3px 0 #ff004c;
  animation: wm-slice-b 0.21s steps(1) infinite;
}

@keyframes wm-jitter {
  0%   { transform: translate(0, 0) skewX(0); }
  50%  { transform: translate(-2px, 1px) skewX(-6deg); }
  100% { transform: translate(2px, -1px) skewX(4deg); }
}

@keyframes wm-slice-a {
  0%   { clip-path: inset(8% 0 72% 0);  transform: translateX(-7px); }
  25%  { clip-path: inset(55% 0 20% 0); transform: translateX(5px); }
  50%  { clip-path: inset(30% 0 52% 0); transform: translateX(-4px); }
  75%  { clip-path: inset(78% 0 4% 0);  transform: translateX(8px); }
}

@keyframes wm-slice-b {
  0%   { clip-path: inset(62% 0 14% 0); transform: translateX(6px); }
  25%  { clip-path: inset(14% 0 66% 0); transform: translateX(-8px); }
  50%  { clip-path: inset(44% 0 38% 0); transform: translateX(4px); }
  75%  { clip-path: inset(2% 0 84% 0);  transform: translateX(-5px); }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark.glitch, .wordmark.glitch::before, .wordmark.glitch::after { animation: none; }
}

[hidden] { display: none !important; }

/* ---------- Phones ---------- */
@media (max-width: 700px) {
  main { padding: 80px 16px 52px; }
  .meta { white-space: normal; } /* long gear line wraps under narrow portraits */
  .wordmark { top: 20px; left: 16px; font-size: calc(var(--mark-size) * 0.8); }
  .contact { bottom: 14px; right: 16px; }
}

/* ---------- Phones turned sideways ----------
   Too short to stack the count and info above/below the photo, so the photo
   gets the full height and everything else moves into the side gutters. */
@media (orientation: landscape) and (max-height: 500px) {
  main { padding: 12px clamp(120px, 20vw, 190px); }

  .wordmark { top: 14px; left: 16px; font-size: calc(var(--mark-size) * 0.55); }
  .contact { bottom: 10px; right: 16px; font-size: calc(var(--mark-size) * 0.5); }

  figure header,
  figure footer {
    position: fixed;
    width: auto;
    min-width: 0;
    margin: 0;
  }
  figure header { top: 16px; right: 16px; }
  figure footer {
    bottom: 14px;
    left: 16px;
    width: calc(clamp(120px, 20vw, 190px) - 32px);
  }
  .meta { white-space: normal; font-size: 10px; }
}
