/* ==========================================================================
   Reset
   ========================================================================== */

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

/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  font-size: 62.5%; /* 1rem = 10px */
  --bg: #0e0d0b;
  --font-serif: PitchSans, Georgia, serif;
  --font-mono: PitchSans, monospace;
  --stage-padding: 6vw;
}

/* Default dark theme colors */
body {
  --fg: #e8e2d4;
  --dim: #a8a299;
  --accent: #e8e2d4;
}

/* Light theme colors (for light backgrounds) */
body[data-theme="light"] {
  --fg: #1a1815;
  --dim: #5a5650;
  --accent: #1a1815;
}

/* Dark theme colors (for dark backgrounds) */
body[data-theme="dark"] {
  --fg: #e8e2d4;
  --dim: #a8a299;
  --accent: #e8e2d4;
}

/* ==========================================================================
   Base
   ========================================================================== */

html, body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-size: 1.4rem;
  font-family: var(--font-mono);
  line-height: 1.5;
  transition: color 0.4s ease;
}

a {
  color: var(--fg);
  text-decoration: none;
  transition: color 0.4s ease;
}

a:hover {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 0.05em;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: auto;
}

/* Content links (about page, etc.) have permanent underlines */
main p a,
main section a {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 0.05em;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: auto;
  transition: background-color 0.2s ease;
}

main p a:hover,
main section a:hover {
  background-color: rgba(255, 230, 100, 0.45);
  text-decoration-thickness: 0.08em;
}

p { margin-bottom: 1.4rem; }

@view-transition {
  navigation: auto;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

*:focus {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  background: var(--fg);
  color: var(--bg);
  padding: 8px 16px;
  font-size: 1.4rem;
  z-index: 100;
}

.skip-link:focus {
  position: absolute;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  overflow: visible;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Photo viewer layout
   ========================================================================== */

body.viewer {
  height: 100%;
  overflow: hidden;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height - adapts to Safari toolbars */
  display: grid;
  grid-template-rows: 1fr auto;
  position: relative;
}

body.info {
  overflow: hidden;
}

body.info main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

body.info main::before {
  content: '';
  position: absolute;
  top: clamp(-150%, calc(100vh - 680px), 20%);
  left: clamp(70%, 30vw, 100%);
  transform: translate(-40%, -40%);
  width: 500px;
  height: 400px;
  background-image: url('/assets/images/20240216-DSC07893-JenSchuetz.jpg');
  background-size: cover;
  background-position: center;
  filter: grayscale(100%);
  opacity: 0.2;
  mix-blend-mode: screen;
  z-index: 0;
  pointer-events: none;
}


/* ==========================================================================
   Header — shared
   ========================================================================== */
   
body.past #header,
body.info #header {
  background-color: var(--bg);
}

#header {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 24px 36px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom)); /* Account for iPhone notch/home indicator */
  padding-left: calc(36px + env(safe-area-inset-left));
  padding-right: calc(36px + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

#wordmark {
  color: var(--fg);
  font-weight: 600;
  opacity: 0.75;
  text-transform: uppercase;
  pointer-events: all;
  transition: opacity 0.2s ease, color 0.4s ease;
}

#wordmark:hover {
  opacity: 0.85;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 0.05em;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: auto;
}

#header-right {
  display: flex;
  gap: clamp(8px, 3vw, 16px);
  align-items: center;
}

#header-right a {
  color: var(--fg);
  pointer-events: all;
  transition: color 0.4s ease;
}

#header-right a:hover,
#header-right a[aria-current="page"] {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 0.05em;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: auto;
}

#past-link:hover,
#feed-link:hover,
#back-link:hover {
  color: var(--fg);
}

#counter {
  color: var(--dim);
  line-height: 1.8;
  text-align: right;
  transition: color 0.4s ease;
}

/* ==========================================================================
   Photo viewer — stage
   ========================================================================== */

#stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#photo-wrap {
  position: relative;
  max-width: 88vw;
  max-width: 88dvw;
  max-height: 84vh;
  max-height: 84dvh; /* Dynamic viewport - adapts to Safari toolbars */
  display: flex;
  align-items: center;
  justify-content: center;
}

#photo {
  display: block;
  max-width: 88vw;
  max-width: 88dvw;
  max-height: 84vh;
  max-height: 84dvh; /* Dynamic viewport - adapts to Safari toolbars */
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#photo.loaded { opacity: 1; }

/* ==========================================================================
   Photo viewer — caption bar
   ========================================================================== */

#caption-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 28px 36px;
  padding-top: calc(28px + env(safe-area-inset-top)); /* Account for iPhone notch/status bar */
  padding-left: calc(36px + env(safe-area-inset-left));
  padding-right: calc(36px + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

#caption {
  font-family: var(--font-serif);
  color: var(--fg);
  opacity: 0.75;
  max-width: 50ch;
  line-height: 1.5;
  transition: opacity 0.4s ease, color 0.4s ease;
}

#date {
  color: var(--fg);
  text-align: right;
  transition: color 0.4s ease;
}

#date:hover {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 0.05em;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: auto;
}

/* ==========================================================================
   Photo viewer — navigation
   ========================================================================== */

#nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  background: none;
  border: 1px solid var(--dim);
  cursor: pointer;
  padding: 0px 5px;
  transition: color 0.2s ease, border-color 0.2s ease;
  border-radius: 2px;
  user-select: none;
}

a.nav-btn {
  color: var(--dim);
}

a.nav-btn:hover {
  opacity: 0.6;
}

span.nav-btn {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

/* ==========================================================================
   Past grid
   ========================================================================== */

#grid {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  max-width: 2400px;
  margin: 0 auto;
}

.photo-item {
  display: block;
  transition: transform 0.2s ease;
  view-transition-name: none;
}

#grid {
  view-transition-name: none;
}

.photo-item:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.photo-item:hover .photo-thumb {
  border: 1px solid var(--fg);
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  border: 1px solid transparent;
  transition: border 0.2s ease;
}

.photo-meta {
  padding: 12px 0;
}

.photo-date {
  color: var(--dim);
  opacity: 0.5;
  margin-bottom: 6px;
}

.photo-caption {
  font-family: var(--font-serif);
  color: var(--fg);
  opacity: 0.75;
  line-height: 1.4;
}



/* ==========================================================================
   Info
   ========================================================================== */
   
.info {
  margin-inline: auto;
  max-width: 600px;
}

body.info section {
  position: relative;
  z-index: 1;
}


/* ==========================================================================
   Loading state — shared
   ========================================================================== */

#loading {
  padding: 60px 36px;
  text-align: center;
  letter-spacing: 0.2em;
  color: var(--dim);
  transition: color 0.4s ease;
}

body.viewer #loading {
  position: fixed;
  inset: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  #grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 2rem;
  }
  #header,
  #caption-bar {
    padding-left: 6vw;
    padding-right: 6vw;
  }
  .info {
    width: 100%;
    padding-left: 6vw;
    padding-right: 6vw;
  }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #photo {
    transition: none;
  }
}

/* ==========================================================================
 Fonts
 ========================================================================== */
 
@font-face {
     font-family: "PitchSans";
     src: url("/assets/fonts/pitchSans-Medium.woff2") format("woff2");
     font-weight: 500;
     font-style: normal;
     font-display: swap;
 }
 
 @font-face {
      font-family: "PitchSans";
      src: url("/assets/fonts/pitchSans-Bold.woff2") format("woff2");
      font-weight: 600;
      font-style: normal;
      font-display: swap;
  }
