/*
 * Worker — Foundation Tokens
 *
 * These are structural defaults. Every project overrides
 * the brand slots (ink, surface, accent, fonts, radius)
 * in its own theme.css. The spacing scale, type scale,
 * layout, and motion tokens stay the same everywhere.
 */

:root {
  /* ── Brand color slots (override per project) ─────────── */
  --color-ink:             #111827;
  --color-ink-muted:       #6b7280;
  --color-surface:         #ffffff;
  --color-surface-raised:  #ffffff;
  --color-surface-sunken:  #f3f4f6;
  --color-surface-overlay: rgba(0, 0, 0, 0.9);
  --color-line:            rgba(0, 0, 0, 0.08);
  --color-line-strong:     rgba(0, 0, 0, 0.16);
  --color-accent:          #111827;
  --color-accent-hover:    #374151;
  --color-accent-light:    #f3f4f6;
  --color-accent-2:        #3b5d4a;
  --color-accent-3:        #d4a853;
  --color-focus:           #111827;

  /* ── Status ───────────────────────────────────────────── */
  --color-success:         #16a34a;
  --color-warning:         #d97706;
  --color-error:           #dc2626;

  /* ── Spacing (4px base) ───────────────────────────────── */
  --space-1:   0.25rem;
  --space-2:   0.5rem;
  --space-3:   0.75rem;
  --space-4:   1rem;
  --space-6:   1.5rem;
  --space-8:   2rem;
  --space-12:  3rem;
  --space-16:  4rem;
  --space-20:  5rem;
  --space-24:  6rem;
  --space-32:  8rem;

  /* ── Type scale ───────────────────────────────────────── */
  --text-hero:     clamp(3.5rem, 6vw, 5.5rem);
  --text-h1:       clamp(2.5rem, 4vw, 3.5rem);
  --text-h2:       clamp(1.75rem, 2.5vw, 2.25rem);
  --text-h3:       clamp(1.25rem, 1.8vw, 1.5rem);
  --text-body-lg:  1.125rem;
  --text-body:     1rem;
  --text-small:    0.875rem;
  --text-micro:    0.75rem;

  /* ── Font families (override per project) ─────────────── */
  --font-display:  system-ui, sans-serif;
  --font-body:     system-ui, sans-serif;
  --font-mono:     'Courier New', monospace;

  /* ── Font weights ─────────────────────────────────────── */
  --weight-regular:    400;
  --weight-medium:     500;
  --weight-semibold:   600;
  --weight-bold:       700;

  /* ── Radius (override per project) ────────────────────── */
  --radius-none:   0px;
  --radius-sm:     4px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --radius-full:   9999px;

  /* ── Shadows ──────────────────────────────────────────── */
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:     0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg:     0 10px 15px rgba(0,0,0,0.1);
  --shadow-none:   none;

  /* ── Motion ───────────────────────────────────────────── */
  --ease-out:          cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast:     150ms;
  --duration-normal:   250ms;
  --duration-slow:     400ms;

  /* ── Layout ───────────────────────────────────────────── */
  --page-width:        min(100% - 2.5rem, 75rem);
  --copy-width:        min(100% - 2.5rem, 45rem);
  --wide-width:        min(100% - 2.5rem, 87.5rem);
  --gutter:            clamp(1rem, 2vw, 2rem);
  --nav-height:        4.5rem;
}

/*
 * Clearwater — Theme Tokens
 * lucyandmorg.wedding
 *
 * Overrides the brand slots from base.css and adds
 * project-specific tokens for the gallery and viewer.
 */

:root {
  /* ── Brand palette ─────────────────────────────────────── */
  /* Warm cream — the site's defining colour, from the wedding */
  --color-ink:             #121212;
  --color-ink-muted:       rgba(18, 18, 18, 0.58);
  --color-surface:         #f3eee7;
  --color-surface-raised:  rgba(243, 238, 231, 0.84);  /* translucent header */
  --color-surface-sunken:  rgba(243, 238, 231, 0.94);
  --color-surface-overlay: rgba(10, 10, 10, 0.90);     /* full-screen viewer */
  --color-line:            rgba(18, 18, 18, 0.12);
  --color-line-strong:     rgba(18, 18, 18, 0.22);
  --color-focus:           #121212;

  /* Monochromatic — ink is the accent */
  --color-accent:          #121212;
  --color-accent-hover:    #2a2a2a;
  --color-accent-light:    rgba(18, 18, 18, 0.06);

  /* ── On-overlay palette ────────────────────────────────── */
  /* Used exclusively inside the dark full-screen photo viewer */
  --color-on-overlay:           rgba(255, 255, 255, 0.82);
  --color-on-overlay-secondary: rgba(255, 255, 255, 0.72);
  --color-on-overlay-muted:     rgba(255, 255, 255, 0.60);
  --color-on-overlay-dim:       rgba(255, 255, 255, 0.20);
  --color-on-overlay-strong:    rgba(255, 255, 255, 0.95);
  --color-on-overlay-full:      #ffffff;
  --color-save-idle:            rgba(255, 255, 255, 0.75);

  /* ── Gallery-specific ──────────────────────────────────── */
  --color-image-bg:  rgba(18, 18, 18, 0.05);  /* placeholder while loading */
  --color-selection: rgba(18, 18, 18, 0.16);  /* ::selection highlight */

  /* ── Shadows ───────────────────────────────────────────── */
  --shadow-text-overlay:      0 1px 4px rgba(0, 0, 0, 0.50);  /* save chip */
  --shadow-text-overlay-soft: 0 1px 4px rgba(0, 0, 0, 0.45);  /* timestamp */

  /* ── Fonts ─────────────────────────────────────────────── */
  --font-display: 'Cormorant Garant', Georgia, serif;
  --font-body:    'Instrument Sans', system-ui, sans-serif;

  /* ── Radius — sharp/editorial, no rounding ─────────────── */
  --radius-sm:   0px;
  --radius-md:   0px;
  --radius-lg:   0px;

  /* ── Motion — intimate pace, slightly slower than base ─── */
  --duration-fast:        160ms;
  --duration-normal:      220ms;
  --duration-image-hover: 360ms;

  /* ── Layout ────────────────────────────────────────────── */
  --page-width:  min(100% - 2.5rem, 112rem);  /* wider for editorial gallery */
  --copy-width:  min(100% - 2.5rem, 46rem);   /* subpage shell */
  --nav-height:  4.5rem;
  --stream-gap:  clamp(0.85rem, 1.8vw, 1.5rem);
  --page-top:    calc(var(--nav-height) + clamp(1rem, 2vw, 1.5rem));
  --blur-glass:  16px;

  /* ── Typography extras ─────────────────────────────────── */
  --text-page-title: clamp(1.8rem, 3vw, 2.8rem);
  --text-caption:    0.78rem;   /* image caption */
  --text-stamp:      0.65rem;   /* EXIF timestamp overlay */

  /* ── Component dimensions ──────────────────────────────── */
  --width-topline:              34rem;
  --width-copy-text:            30rem;
  --caption-gap:                0.6rem;
  --caption-width:              16rem;
  --caption-width-narrow:       14rem;
  --field-height:               3rem;
  --field-padding-y:            0.9rem;
  --viewer-image-max:           88rem;
  --viewer-chrome-height:       8rem;
  --viewer-chrome-height-mobile: 10rem;
  --header-padding-mobile:      0.35rem;
  --timestamp-offset:           0.4rem;
  --page-top-mobile:            6.75rem;
  --aside-gap:                  clamp(1.5rem, 4vw, 5rem);
  --aside-min-height:           clamp(28rem, 56vw, 48rem);
}

/* Base and theme tokens are prepended by the build (base.css → theme.css). */
/* This file contains only selectors — no hardcoded values.                 */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img,
video {
  display: block;
  max-width: 100%;
}

a,
button,
input {
  font: inherit;
  color: inherit;
}

a {
  text-decoration: none;
}

button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--color-selection);
}

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

.page {
  min-height: 100vh;
}

.shell-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  padding: 0 var(--gutter);
  transition:
    background-color var(--duration-normal) ease,
    border-color var(--duration-normal) ease,
    backdrop-filter var(--duration-normal) ease;
}

.shell-header.is-scrolled,
.shell-header--solid {
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-line);
  backdrop-filter: blur(var(--blur-glass));
}

.shell-header__inner {
  width: var(--page-width);
  min-height: var(--nav-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.shell-title,
.shell-nav a,
.page-kicker,
.utility-button,
.utility-link,
.gallery-stream__message,
.upload-form__status,
.field span,
.viewer__details,
.viewer__index {
  font-size: var(--text-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shell-title {
  font-weight: var(--weight-medium);
}

.shell-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-4);
}

.shell-nav a {
  color: var(--color-ink-muted);
  transition: color var(--duration-fast) ease;
}

.shell-nav a[aria-current="page"],
.shell-nav a:hover,
.shell-nav a:focus-visible {
  color: var(--color-ink);
}

.gallery-page,
.subpage-shell {
  width: var(--page-width);
  margin: 0 auto;
  padding: var(--page-top) var(--gutter) var(--space-16);
}

.gallery-page {
  display: grid;
  gap: var(--space-6);
}

.gallery-page--saved {
  gap: var(--space-4);
}

.page-topline,
.subpage-copy {
  width: min(100%, var(--width-topline));
}

.subpage-shell {
  width: var(--copy-width);
  display: grid;
  gap: var(--space-12);
}

.page-kicker {
  color: var(--color-ink-muted);
}

.page-title {
  margin: var(--space-3) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-page-title);
  font-weight: var(--weight-medium);
  line-height: 1.05;
}

.page-copy {
  max-width: var(--width-copy-text);
  margin: var(--space-4) 0 0;
  color: var(--color-ink-muted);
}

.gallery-stream {
  display: grid;
  gap: var(--stream-gap);
}

.stream-row {
  display: grid;
  gap: var(--stream-gap);
  align-items: start;
}

.image-tile {
  position: relative;
  min-width: 0;
}

.image-tile__open {
  display: block;
  width: 100%;
  text-align: left;
}

.image-tile__frame {
  background: var(--color-image-bg);
}

.image-tile__image {
  width: 100%;
  height: auto;
  vertical-align: middle;
  transition:
    opacity var(--duration-normal) ease,
    transform var(--duration-image-hover) ease;
}

.image-tile__open:hover .image-tile__image,
.image-tile__open:focus-visible .image-tile__image {
  opacity: 0.96;
  transform: scale(1.006);
}

.save-chip {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 2;
  color: var(--color-save-idle);
  text-shadow: var(--shadow-text-overlay);
  text-decoration: underline;
  text-decoration-color: var(--color-on-overlay-dim);
  text-underline-offset: 2px;
  opacity: 0;
  transition:
    opacity var(--duration-fast) ease,
    color var(--duration-fast) ease,
    text-decoration-color var(--duration-fast) ease;
}

.image-tile:hover .save-chip,
.image-tile:focus-within .save-chip {
  opacity: 1;
}

.save-chip[aria-pressed="true"] {
  color: var(--color-on-overlay-full);
  text-decoration-color: var(--color-on-overlay-secondary);
  opacity: 1;
}

.image-tile__timestamp {
  position: absolute;
  bottom: calc(var(--space-3) + var(--timestamp-offset));
  left: var(--space-3);
  z-index: 2;
  margin: 0;
  font-size: var(--text-stamp);
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--color-on-overlay-muted);
  text-shadow: var(--shadow-text-overlay-soft);
  text-decoration: none;
  pointer-events: none;
}

.image-tile__caption,
.stream-row__aside p {
  margin: 0;
  padding-top: var(--caption-gap);
  font-size: var(--text-caption);
  line-height: 1.1;
  font-weight: var(--weight-medium);
  max-width: var(--caption-width);
}

.image-tile__caption--center {
  margin-inline: auto;
  text-align: center;
}

.image-tile__caption--end {
  margin-left: auto;
  text-align: right;
}

.stream-row--aside {
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
}

.stream-row__aside {
  display: grid;
  align-content: end;
  min-height: 100%;
}

.gallery-stream__sentinel {
  height: 1px;
}

.gallery-stream__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-ink-muted);
}

.utility-button,
.utility-link {
  display: inline-flex;
  align-items: center;
  text-decoration: underline;
  text-decoration-color: var(--color-line-strong);
  text-underline-offset: 3px;
  transition:
    text-decoration-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

.utility-button:hover,
.utility-button:focus-visible,
.utility-link:hover,
.utility-link:focus-visible {
  text-decoration-color: var(--color-ink);
}

.utility-button--filled {
  font-weight: var(--weight-medium);
  text-decoration-color: var(--color-ink);
}

.viewer {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: stretch;
  padding: var(--gutter);
  background: var(--color-surface-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) ease;
  z-index: 70;
}

.viewer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.viewer__chrome {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.viewer__meta {
  display: grid;
  gap: var(--space-1);
  color: var(--color-on-overlay);
}

.viewer__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-3);
}

.viewer .utility-button {
  color: var(--color-on-overlay-secondary);
  text-decoration-color: var(--color-on-overlay-dim);
}

.viewer .utility-button:hover,
.viewer .utility-button:focus-visible,
.viewer .utility-button[aria-pressed="true"] {
  color: var(--color-on-overlay-strong);
  text-decoration-color: var(--color-on-overlay-muted);
}

.viewer__frame {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 0;
}

.viewer__frame img {
  max-width: min(100%, var(--viewer-image-max));
  max-height: calc(100vh - var(--viewer-chrome-height));
  width: auto;
  height: auto;
  object-fit: contain;
}

.viewer__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-on-overlay-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-on-overlay-dim);
  text-underline-offset: 3px;
  transition:
    color var(--duration-fast) ease,
    text-decoration-color var(--duration-fast) ease;
}

.viewer__nav:hover,
.viewer__nav:focus-visible {
  color: var(--color-on-overlay-strong);
  text-decoration-color: var(--color-on-overlay-muted);
}

.viewer__nav--prev {
  left: var(--gutter);
}

.viewer__nav--next {
  right: var(--gutter);
}

.upload-form {
  display: grid;
  gap: var(--space-6);
}

.upload-form__grid {
  display: grid;
  gap: var(--space-6);
}

.field {
  display: grid;
  gap: var(--space-3);
}

.field span {
  color: var(--color-ink-muted);
}

.field input {
  width: 100%;
  min-height: var(--field-height);
  padding: 0 0 var(--field-padding-y);
  border: 0;
  border-bottom: 1px solid var(--color-line-strong);
  border-radius: 0;
  background: transparent;
}

.field input:focus-visible {
  outline: none;
  border-bottom-color: var(--color-ink);
}

.field--file input {
  min-height: auto;
  padding-bottom: 0;
}

.upload-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.upload-form__status {
  min-height: var(--text-body);
  color: var(--color-ink-muted);
}

.upload-form__status[data-state="error"] {
  color: var(--color-ink);
}

.upload-form__status[data-state="success"] {
  color: var(--color-ink);
}

.upload-form__note {
  color: var(--color-ink-muted);
}

.empty-state {
  color: var(--color-ink-muted);
}

@media (min-width: 52rem) {
  .stream-row--duo {
    grid-template-columns: minmax(0, var(--row-a, 1fr)) minmax(0, var(--row-b, 1fr));
  }

  .stream-row--aside {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
    column-gap: var(--aside-gap);
    min-height: var(--aside-min-height);
  }

  .stream-row--aside-right {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  }

  .stream-row--aside .image-tile {
    align-self: start;
  }

  .stream-row--aside .image-tile__caption {
    max-width: var(--caption-width-narrow);
  }

  .upload-form__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 51.999rem) {
  :root {
    --nav-height: auto;
    --page-top: var(--page-top-mobile);
  }

  .shell-header {
    padding-top: var(--header-padding-mobile);
    padding-bottom: var(--header-padding-mobile);
  }

  .shell-header__inner {
    align-items: flex-start;
    flex-direction: column;
    padding: var(--header-padding-mobile) 0;
    gap: var(--space-3);
  }

  .shell-nav {
    justify-content: flex-start;
    gap: var(--space-3);
  }

  .stream-row--aside {
    min-height: auto;
  }

  .save-chip {
    opacity: 1;
  }

  .viewer {
    padding: var(--space-4);
  }

  .viewer__frame img {
    max-height: calc(100vh - var(--viewer-chrome-height-mobile));
  }

  .viewer__nav {
    top: auto;
    bottom: var(--space-4);
    transform: none;
  }

  .viewer__nav--prev {
    left: var(--space-4);
  }

  .viewer__nav--next {
    right: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
