:root {
  --navy-950: #01122a; /* the crest's own background, so it sits seamlessly on the page */
  --navy-900: #061a38;
  --navy-800: #0c2650;
  --navy-700: #163768;
  --gold: #c9a24a;
  --gold-bright: #e6c477;
  --gold-dim: #6f5726;
  --cream: #f3ead6;
  --cream-muted: #b9b2a3;
  --danger: #f0a08f;
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
  --gutter: clamp(16px, 4vw, 40px);
  --content: 1120px;
  color-scheme: dark;
}

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

/* Component display rules (buttons are inline-flex) must not override hiding. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--navy-950);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 1.1875rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
}

a {
  color: var(--gold-bright);
  text-underline-offset: 3px;
}

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

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Typography */

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.1;
  margin: 0;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0;
}

.lead {
  font-size: 1.3125rem;
  font-style: italic;
  color: var(--cream-muted);
  max-width: 36em;
  margin: 0 auto;
}

.flourish {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 20px auto;
}

.flourish::before,
.flourish::after {
  content: "";
  height: 1px;
  width: min(140px, 28vw);
  background: linear-gradient(to right, transparent, var(--gold));
}

.flourish::after {
  transform: scaleX(-1);
}

.flourish span {
  width: 7px;
  height: 7px;
  background: var(--gold);
  transform: rotate(45deg);
}

/* Header and footer */

.site-header {
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
}

.site-header .inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--cream);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.22em;
  font-size: 1rem;
}

.wordmark img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 30%;
  border: 1px solid var(--gold-dim);
}

.site-nav {
  display: flex;
  gap: clamp(12px, 3vw, 28px);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--cream-muted);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
}

.site-footer {
  text-align: center;
  padding: 40px var(--gutter) 32px;
  color: var(--cream-muted);
  font-size: 0.9375rem;
}

.site-footer .eyebrow {
  font-size: 0.6875rem;
  color: var(--gold-dim);
}

/* Buttons and forms */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: var(--gold);
  color: var(--navy-950);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}

.button:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
}

.button.ghost {
  background: transparent;
  color: var(--gold-bright);
}

.button.ghost:hover {
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}

.field {
  display: grid;
  gap: 6px;
  text-align: left;
}

.field label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  background: var(--navy-900);
  color: var(--cream);
  font: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent);
}

.error {
  color: var(--danger);
}

/* A panel with the double gilt rule of the crest's shield. */
.panel {
  position: relative;
  background: var(--navy-900);
  border: 1px solid var(--gold-dim);
  padding: clamp(20px, 4vw, 36px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid color-mix(in srgb, var(--gold) 18%, transparent);
  pointer-events: none;
}

/* Home */

.home {
  max-width: var(--content);
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  text-align: center;
}

.crest {
  /* Feather the image edges so the crest's textured background melts into the page. */
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent),
    linear-gradient(to bottom, transparent, #000 4%, #000 96%, transparent);
  mask-composite: intersect;
}

.home .crest {
  width: min(480px, 100%);
  margin: 0 auto;
}

.home .lead {
  margin-top: 4px;
}

.home-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 20px;
  max-width: 720px;
  margin: 40px auto 0;
}

.home-card {
  display: block;
  color: var(--cream);
  text-decoration: none;
  text-align: left;
  transition: border-color 150ms, transform 150ms;
}

.home-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.home-card h2 {
  font-size: 1.375rem;
  margin: 8px 0;
}

.home-card p {
  margin: 0;
  color: var(--cream-muted);
}

.home-card .more {
  display: inline-block;
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

/* Sign in */

.signin {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px var(--gutter) 48px;
  text-align: center;
}

.signin .crest {
  width: min(300px, 80%);
  margin: 0 auto 8px;
}

.signin .motto {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  margin: 0 0 8px;
}

.signin form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.signin .error {
  margin: 0;
}

/* Event page */

.event-hero {
  text-align: center;
  padding: clamp(40px, 8vw, 80px) var(--gutter) 24px;
}

.event-hero h1 {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  margin-top: 12px;
}

.event-hero h1 .year {
  display: block;
  color: var(--gold);
  font-size: 0.55em;
  letter-spacing: 0.3em;
  margin-top: 8px;
}

/* Album page */

.album {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--gutter) 40px;
}

/* Stays pinned while scrolling, so Upload and Select are always in reach. */
.album-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 14px;
  background: var(--navy-950);
}

.album-title h1 {
  font-size: clamp(1.5rem, 6vw, 2.25rem);
}

.album-title .year {
  color: var(--gold);
}

.album-title p {
  margin: 2px 0 0;
  color: var(--cream-muted);
  font-style: italic;
  font-size: 1rem;
}

.album-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.album-actions .button,
.selection-actions .button {
  min-height: 42px;
  padding: 0 16px;
}

/* Bottom sheet on phones, centred dialog on larger screens. */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 20px var(--gutter) 28px;
  border: 1px solid var(--gold-dim);
  border-bottom: 0;
  background: var(--navy-900);
  color: var(--cream);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet[open] {
  display: grid;
  gap: 18px;
}

.sheet::backdrop {
  background: rgb(0 6 16 / 0.7);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-header h2 {
  font-size: 1.25rem;
}

.sheet p {
  margin: 0;
}

.sheet progress {
  width: 100%;
  height: 4px;
  appearance: none;
  border: 0;
  background: var(--navy-700);
}

.sheet progress::-webkit-progress-bar {
  background: var(--navy-700);
}

.sheet progress::-webkit-progress-value {
  background: var(--gold);
}

.sheet progress::-moz-progress-bar {
  background: var(--gold);
}

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-bottom: 1px solid var(--gold-dim);
  }
}

/* Once a batch finishes, the upload panel shows the summary instead of the picker. */
.sheet.finished .field,
.sheet.finished .dropzone {
  display: none;
}

.sheet-summary {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 8px 0;
  text-align: center;
}

.sheet-summary-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold-bright);
  font-size: 1.5rem;
}

.sheet-summary-actions {
  display: flex;
  gap: 8px;
}

.selection-bar {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--gold-dim);
  background: var(--navy-900);
}

.selection-actions {
  display: flex;
  gap: 8px;
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

body.selecting {
  padding-bottom: 76px;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: clamp(28px, 6vw, 48px) 16px;
  border: 1px dashed var(--gold-dim);
  text-align: center;
  transition: border-color 150ms, background 150ms;
}

.dropzone.dragging {
  border-color: var(--gold-bright);
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}

.dropzone p {
  margin: 0;
  color: var(--cream-muted);
}

.dropzone[aria-disabled="true"] .button {
  opacity: 0.45;
  pointer-events: none;
}

.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.queue:empty {
  display: none;
}

.queue li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  font-size: 1rem;
}

.queue .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue .status {
  color: var(--cream-muted);
  font-style: italic;
}

.queue .done .status {
  color: var(--gold-bright);
}

.queue .failed .status {
  color: var(--danger);
}

.queue progress {
  grid-column: 1 / -1;
}

/* Gallery */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(30%, 180px), 1fr));
  gap: 6px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: var(--navy-800);
  cursor: zoom-in;
  overflow: hidden;
}

.tile img,
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms;
}

.tile:hover img,
.tile:hover video {
  transform: scale(1.04);
}

.tile .check {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.3);
  color: transparent;
  font-size: 0.875rem;
  font-weight: 700;
}

.selecting .tile {
  cursor: pointer;
}

.selecting .tile .check {
  display: grid;
}

.tile[aria-pressed="true"] .check {
  border-color: var(--gold-bright);
  background: var(--gold-bright);
  color: var(--navy-950);
}

.tile[aria-pressed="true"] img,
.tile[aria-pressed="true"] video {
  opacity: 0.7;
  transform: scale(0.9);
}

.tile .badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgb(1 18 42 / 0.75);
  color: var(--cream);
  font-size: 0.75rem;
}

.empty {
  margin-top: 8px;
  text-align: center;
  padding: 48px 16px;
  color: var(--cream-muted);
  font-style: italic;
  border: 1px solid color-mix(in srgb, var(--gold) 18%, transparent);
}

/* Lightbox */

/* Freeze the album underneath while a photo is open. */
html:has(.viewer[open]),
html:has(.sheet[open]) {
  overflow: hidden;
}

.viewer {
  overflow: hidden;
  overscroll-behavior: contain;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(0 6 16 / 0.96);
  color: var(--cream);
}

.viewer::backdrop {
  background: rgb(0 6 16 / 0.85);
}

.viewer[open] {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--gutter);
}

.viewer-stage {
  position: relative;
  min-height: 0;
}

/* Native horizontal scrolling with snap points gives finger-following, iPhone-style swipes. */
.viewer-track {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-x;
}

.viewer-track::-webkit-scrollbar {
  display: none;
}

/* While zoomed, one finger pans the photo instead of swiping to the next. */
.viewer-track.zoomed {
  overflow-x: hidden;
  touch-action: none;
}

.viewer-slide {
  position: relative;
  flex: 0 0 100%;
  overflow: hidden;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Inset 8px either side, so neighbouring photos have a gap between them mid-swipe. */
.viewer-slide img,
.viewer-slide video {
  position: absolute;
  inset: 0 8px;
  width: calc(100% - 16px);
  height: 100%;
  max-width: none;
  object-fit: contain;
}

.viewer-slide img {
  transform-origin: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.viewer-slide img.settling {
  transition: transform 0.25s ease;
}

.viewer-footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px var(--gutter) 20px;
}

.viewer-caption {
  margin: 0;
  text-align: center;
  text-wrap: balance;
  color: var(--cream-muted);
  font-style: italic;
}

.viewer-footer .icon-button {
  min-width: 56px;
  height: 52px;
}

.icon-button {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  background: rgb(1 18 42 / 0.6);
  color: var(--cream);
  font: inherit;
  font-size: 1.125rem;
  text-decoration: none;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.viewer-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 600px) {
  .site-header .inner {
    flex-direction: column;
    gap: 6px;
  }

  .album-actions .button,
  .selection-actions .button {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
