/* =========================================================
   noteriks.photo — Green Room
   Editorial library reading room aesthetic
   ========================================================= */

/* ---------- Self-hosted serif italic ---------- */
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/SourceSerif4-Italic.woff2') format('woff2');
}

/* ---------- Design tokens ---------- */
:root {
  /* Color */
  --ink:          #f3ecd8;  /* warm cream */
  --paper:        #0f2a22;  /* deep racing emerald */
  --tile:         #163b31;  /* lifted emerald */
  --tile-active:  #1c4a3c;  /* further-lifted emerald */
  --accent:       #e9a252;  /* brass */
  --secondary:    #e67a66;  /* soft coral */
  --tertiary:     #d8c4a0;  /* blush oat */
  --masthead:     var(--accent);

  /* Typography — sans is system, serif is self-hosted, mono is system */
  --font-sans:  "Helvetica Neue", "Inter", Helvetica, Arial, sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono:  ui-monospace, "SF Mono", Menlo, monospace;

  /* Spacing */
  --gutter-d: 32px;
  --gutter-t: 24px;
  --gutter-m: 20px;
  --gutter-w: clamp(32px, 1.6vw + 8px, 56px);
  --col-gap:  clamp(14px, 1vw + 6px, 28px);
  --row-gap:  clamp(20px, 1.4vw + 8px, 36px);

  /* Layout */
  --content-max: 1760px;

  /* Mobile safe areas */
  --safe-top:    max(env(safe-area-inset-top, 0px), 59px);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), 34px);

  /* Motion */
  --ease-row:    cubic-bezier(.7, 0, .2, 1);
  --ease-ink:    cubic-bezier(.4, 0, .2, 1);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  user-select: none;
}

body {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.site-feed {
  flex: 1;
}

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

/* ---------- Paper grain overlay ----------
   Single fixed-position instance below all content (z-index 1).
   On mobile, inset by safe areas so OS chrome stays paper-clean. */
.paper-grain {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: screen;
}

@media (max-width: 599px) {
  .paper-grain {
    top: var(--safe-top);
    bottom: var(--safe-bottom);
  }
}

/* All real content sits above the grain */
.site-header,
.site-feed,
.site-footer,
.exit-wash {
  position: relative;
  z-index: 2;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Banded layout — full-width borders, capped inner content ---------- */
.site-nav,
.site-masthead,
.site-footer {
  /* Outer band keeps the full-viewport border */
  display: block;
}

.site-nav > .band-inner,
.site-masthead > .band-inner,
.site-footer > .band-inner {
  max-width: var(--content-max);
  margin-inline: auto;
  width: 100%;
}

/* ---------- Top nav band ---------- */
.site-nav {
  border-bottom: 1px solid var(--ink);
}

.site-nav > .band-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding-inline: var(--gutter-w);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  /* 44px touch target without enlarging the visual dot */
  position: relative;
}
.nav-dot::after {
  content: '';
  position: absolute;
  inset: -15px;
}

.nav-wordmark {
  font-family: var(--font-sans);
  font-size: clamp(15px, 0.3vw + 13px, 17px);
  font-weight: 600;
  letter-spacing: -0.3px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-index {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 1px;
}

.nav-date {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  opacity: 0.7;
}

@media (max-width: 599px) {
  .site-nav {
    margin-top: var(--safe-top);
  }
  .site-nav > .band-inner {
    padding-inline: var(--gutter-m);
    padding-top: 12px;
    padding-bottom: 12px;
    height: auto;
  }
  .nav-dot { width: 12px; height: 12px; }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .site-nav > .band-inner {
    padding-inline: var(--gutter-t);
  }
}

/* ---------- Masthead band ---------- */
.site-masthead {
  border-bottom: 1px solid var(--ink);
  /* Ink-in start state */
  opacity: 0;
  transform: translateY(6px);
  filter: blur(3px);
  animation: masthead-ink 900ms var(--ease-ink) 80ms forwards;
}

.site-masthead > .band-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(20px, 2.5vw + 8px, 56px) var(--gutter-w) clamp(16px, 1.6vw + 6px, 40px);
}

.masthead-headline {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(34px, 4vw + 8px, 72px);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: clamp(-2.2px, -0.15vw - 0.4px, -1.2px);
}

.masthead-a {
  color: var(--masthead);
}
.masthead-b {
  color: var(--ink);
  margin-left: 0.4ch;
}
.masthead-c {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--tertiary);
  font-weight: 400;
  margin-top: 0.05em;
}

.masthead-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.7;
  margin-top: 8px;
}

@keyframes masthead-ink {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@media (max-width: 599px) {
  .site-masthead {
    transform: translateY(3px);
    filter: blur(2px);
    animation-duration: 700ms;
  }
  .site-masthead > .band-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 20px var(--gutter-m) 16px;
  }
  .masthead-headline {
    line-height: 1.02;
  }
  .masthead-count {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 0;
  }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .site-masthead > .band-inner {
    padding: 32px var(--gutter-t) 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-masthead {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    animation: none !important;
  }
}

/* ---------- Footer band ---------- */
.site-footer {
  border-top: 1px solid var(--ink);
  margin-top: auto; /* pushes footer to bottom of flex column */
}

.site-footer > .band-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding-inline: var(--gutter-w);
}

.footer-left {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 1.5px;
  opacity: 0.7;
}

.footer-right {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--accent);
}

.footer-heart {
  color: var(--accent);
  display: inline-block;
  margin-left: 2px;
}

@media (max-width: 599px) {
  .site-footer > .band-inner {
    padding-inline: var(--gutter-m);
    height: auto;
    padding-top: 12px;
    padding-bottom: calc(12px + var(--safe-bottom));
  }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .site-footer > .band-inner {
    padding-inline: var(--gutter-t);
  }
}

/* ---------- Contact sheet grid ---------- */
.site-feed {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-content: start; /* prevent row stretch on tall viewports (4K etc.) */
  column-gap: var(--col-gap);
  row-gap: var(--row-gap);
  padding: 24px var(--gutter-w);
  /* Cap the grid at the same content width as the bands */
  max-width: var(--content-max);
  margin-inline: auto;
  width: 100%;
}

/* Mobile — single column */
@media (max-width: 599px) {
  .site-feed {
    grid-template-columns: 1fr;
    padding: 20px var(--gutter-m);
    row-gap: var(--row-gap);
  }
}

/* Tablet — two columns */
@media (min-width: 600px) and (max-width: 1023px) {
  .site-feed {
    grid-template-columns: 1fr 1fr;
    padding: 24px var(--gutter-t);
  }
}

/* ---------- Tile chrome ---------- */
.tile {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  outline: none;
  /* Tiles dim when another tile is active */
  opacity: 1;
  transition: opacity 0.3s ease;
}

.tile-frame {
  position: relative;
  background: var(--tile);
  border: 1px solid var(--ink);
  /* Preview frame is the "photo" area; caption sits below */
  aspect-ratio: 16 / 10;
  overflow: hidden;
  transition: background 0.25s ease;
}

.tile-frame--dashed {
  background: transparent;
  border-style: dashed;
  border-color: rgba(243, 236, 216, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-preview {
  position: absolute;
  inset: 0;
  /* Animated SVG mounts here in later phases */
}

.tile-number {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--tile-accent, var(--accent));
}

.tile-placeholder-label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: -0.3px;
  color: rgba(243, 236, 216, 0.6);
}

.tile-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.tile-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.4px solid var(--tile-accent, var(--accent));
}
.tile-corner--tl { top: 6px; left: 6px;     border-right: none; border-bottom: none; }
.tile-corner--tr { top: 6px; right: 6px;    border-left: none;  border-bottom: none; }
.tile-corner--bl { bottom: 6px; left: 6px;  border-right: none; border-top: none; }
.tile-corner--br { bottom: 6px; right: 6px; border-left: none;  border-top: none; }

/* Caption block sits OUTSIDE the frame, below it */
.tile-caption {
  margin-top: clamp(8px, 0.5vw + 6px, 14px);
}

.tile-caption-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.tile-name {
  font-family: var(--font-sans);
  font-size: clamp(15px, 0.5vw + 12px, 18px);
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.tile-year {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  opacity: 0.7;
  color: var(--ink);
}

.tile-desc {
  margin: 4px 0 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(12.5px, 0.4vw + 10px, 15px);
  font-weight: 400;
  line-height: 1.45;
  opacity: 0.9;
  color: var(--ink);
  text-wrap: pretty;
}

/* Focus ring for keyboard navigation */
.tile:focus-visible .tile-frame {
  outline: 2px solid var(--tile-accent, var(--accent));
  outline-offset: 2px;
}

/* ---------- Active tile state (desktop hover OR mobile selected) ---------- */
.tile.is-active .tile-frame {
  background: var(--tile-active);
}
.tile.is-active .tile-corners {
  opacity: 1;
}

/* Sibling dim — set on the feed when any tile is active */
.site-feed.has-active .tile:not(.is-active) {
  opacity: 0.5;
}

/* Desktop scale-shift on hover/focus.
   The active tile scales up; non-active tiles scale down equally so the page
   stays symmetrical and column/row alignment is preserved everywhere. */
@media (min-width: 1024px) {
  .tile {
    transition: transform 550ms var(--ease-row),
                opacity 0.3s ease,
                background 0.25s ease;
    will-change: transform;
    transform-origin: center;
  }
  .tile.is-active {
    transform: scale(1.06);
    z-index: 3;
  }
  .site-feed.has-active .tile:not(.is-active) {
    transform: scale(0.97);
  }
}
