/* Material Design Color System */
:root {
  /* Dark Theme */
  --md-sys-color-primary: #a8c7fa;
  --md-sys-color-on-primary: #0a1929;
  --md-sys-color-primary-container: #1e3a8a;
  --md-sys-color-on-primary-container: #d1e7ff;
  --md-sys-color-secondary: #bec6dc;
  --md-sys-color-on-secondary: #283141;
  --md-sys-color-secondary-container: #3e4759;
  --md-sys-color-on-secondary-container: #dae2f9;
  --md-sys-color-tertiary: #d0bcff;
  --md-sys-color-on-tertiary: #371e73;
  --md-sys-color-tertiary-container: #4f378b;
  --md-sys-color-on-tertiary-container: #eaddff;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;
  --md-sys-color-background: #0f1419;
  --md-sys-color-on-background: #e1e2e8;
  --md-sys-color-surface: #0f1419;
  --md-sys-color-on-surface: #e1e2e8;
  --md-sys-color-surface-variant: #42474e;
  --md-sys-color-on-surface-variant: #c2c7cf;
  --md-sys-color-outline: #8c9199;
  --md-sys-color-outline-variant: #42474e;
  --md-sys-color-shadow: #000000;
  --md-sys-color-scrim: #000000;
  --md-sys-color-inverse-surface: #e1e2e8;
  --md-sys-color-inverse-on-surface: #2e3036;
  --md-sys-color-inverse-primary: #1e3a8a;
  --md-sys-color-surface-dim: #0f1419;
  --md-sys-color-surface-bright: #353a40;
  --md-sys-color-surface-container-lowest: #0a0e13;
  --md-sys-color-surface-container-low: #171c20;
  --md-sys-color-surface-container: #1b2024;
  --md-sys-color-surface-container-high: #252a2f;
  --md-sys-color-surface-container-highest: #30353a;
}

[data-theme="light"] {
  /* Light Theme */
  --md-sys-color-primary: #1e3a8a;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d1e7ff;
  --md-sys-color-on-primary-container: #0a1929;
  --md-sys-color-secondary: #545f71;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #dae2f9;
  --md-sys-color-on-secondary-container: #283141;
  --md-sys-color-tertiary: #6750a4;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #eaddff;
  --md-sys-color-on-tertiary-container: #371e73;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-background: #fefbff;
  --md-sys-color-on-background: #1a1c1e;
  --md-sys-color-surface: #fefbff;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-surface-variant: #dfe2eb;
  --md-sys-color-on-surface-variant: #42474e;
  --md-sys-color-outline: #73777f;
  --md-sys-color-outline-variant: #c2c7cf;
  --md-sys-color-shadow: #000000;
  --md-sys-color-scrim: #000000;
  --md-sys-color-inverse-surface: #2e3036;
  --md-sys-color-inverse-on-surface: #f0f0f7;
  --md-sys-color-inverse-primary: #a8c7fa;
  --md-sys-color-surface-dim: #d9d9e0;
  --md-sys-color-surface-bright: #fefbff;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f3f3fa;
  --md-sys-color-surface-container: #ededf4;
  --md-sys-color-surface-container-high: #e7e8ee;
  --md-sys-color-surface-container-highest: #e1e2e8;
}

/* Material Design Typography Scale */
:root {
  --md-sys-typescale-display-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-display-large-weight: 400;
  --md-sys-typescale-display-large-size: 3.5rem;
  --md-sys-typescale-display-large-line-height: 4rem;
  
  --md-sys-typescale-headline-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-headline-large-weight: 400;
  --md-sys-typescale-headline-large-size: 2rem;
  --md-sys-typescale-headline-large-line-height: 2.5rem;
  
  --md-sys-typescale-title-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-title-large-weight: 400;
  --md-sys-typescale-title-large-size: 1.375rem;
  --md-sys-typescale-title-large-line-height: 1.75rem;
  
  --md-sys-typescale-body-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-body-large-weight: 400;
  --md-sys-typescale-body-large-size: 1rem;
  --md-sys-typescale-body-large-line-height: 1.5rem;
  
  --md-sys-typescale-label-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-label-large-weight: 500;
  --md-sys-typescale-label-large-size: 0.875rem;
  --md-sys-typescale-label-large-line-height: 1.25rem;
}

/* Material Design Elevation */
:root {
  --md-sys-elevation-level0: none;
  --md-sys-elevation-level1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level3: 0px 1px 3px 0px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level4: 0px 2px 3px 0px rgba(0, 0, 0, 0.3), 0px 6px 10px 4px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level5: 0px 4px 4px 0px rgba(0, 0, 0, 0.3), 0px 8px 12px 6px rgba(0, 0, 0, 0.15);
}

/* Base Styles */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  font-family: var(--md-sys-typescale-body-large-font);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-weight);
  overflow-x: hidden; /* prevent accidental horizontal scroll causing right padding */
}

/* Lock body scroll when lightbox is open */
body.no-scroll {
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
}

/* Header Styles */
.site-header {
  background: var(--md-sys-color-surface-container);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--md-sys-elevation-level2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header h1 {
  margin: 0;
  font-family: var(--md-sys-typescale-headline-large-font);
  font-size: var(--md-sys-typescale-headline-large-size);
  font-weight: var(--md-sys-typescale-headline-large-weight);
  line-height: var(--md-sys-typescale-headline-large-line-height);
}

.site-header a {
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  transition: color 0.2s cubic-bezier(0.2, 0.0, 0, 1.0);
}

.site-header a:hover {
  color: var(--md-sys-color-primary);
}

/* Footer Styles */
.site-footer {
  background: var(--md-sys-color-surface-container);
  padding: 24px;
  text-align: center;
  margin-top: 48px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  padding: 12px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s cubic-bezier(0.2, 0.0, 0, 1.0);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
}

.theme-toggle:hover {
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-level1);
}

.theme-toggle:active {
  transform: scale(0.95);
}
/* Layout Styles */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 260px;
  gap: 32px;
  align-items: start;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.left, .center, .right {
  min-height: 100px;
}

.center {
  width: 100%;
}

.left, .right {
  background: var(--md-sys-color-surface-container-low);
  border-radius: 16px;
  padding: 16px;
  box-shadow: none;
  width: 260px;
}

/* Section Titles */
.section-title {
  margin: 0 0 24px 0;
  font-family: var(--md-sys-typescale-title-large-font);
  font-size: var(--md-sys-typescale-title-large-size);
  font-weight: var(--md-sys-typescale-title-large-weight);
  line-height: var(--md-sys-typescale-title-large-line-height);
  color: var(--md-sys-color-on-surface);
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 16px;
}

.grid-3x2 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-3x2 .tile {
  aspect-ratio: 2/3;
  overflow: hidden;
  border-radius: 16px;
  background: var(--md-sys-color-surface-container);
  transition: all 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
  position: relative;
  box-shadow: var(--md-sys-elevation-level1);
}

.grid-3x2 .tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--md-sys-elevation-level3);
}

.grid-3x2 .tile:active {
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-level2);
}

.grid-3x2 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: blur(2px);
  transition: filter 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
}

.grid-3x2 img[data-loaded="true"] {
  filter: none;
}

.grid-day {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.grid-day .tile {
  aspect-ratio: 2/3;
  background: var(--md-sys-color-surface-container);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
  box-shadow: var(--md-sys-elevation-level1);
}

.grid-day .tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--md-sys-elevation-level3);
}

.grid-day .tile:active {
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-level2);
}

.grid-day img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
}

.grid-day .tile:hover img {
  transform: scale(1.05);
}
/* Calendar Styles */
.calendar .month {
  margin-bottom: 24px;
}

.calendar .month-header {
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  line-height: var(--md-sys-typescale-label-large-line-height);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.calendar .days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar .day {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
  transition: all 0.2s cubic-bezier(0.2, 0.0, 0, 1.0);
  cursor: pointer;
}

.calendar .day.active {
  /* Default state for active days: no background/elevation */
  background: transparent;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  box-shadow: none;
}

.calendar .day.active:hover {
  /* On hover: show background only, no elevation */
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: none;
}

/* Current page day: elevated and highlighted by default */
.calendar .day.active.current {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: var(--md-sys-elevation-level2);
}

.calendar .day.active.current:hover {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level3);
}

.calendar .day.disabled {
  background: transparent;
  color: var(--md-sys-color-outline);
  opacity: 0.6;
  cursor: default;
}

.calendar .day.spacer {
  visibility: hidden;
}

/* Ad Placeholder */
.ad-placeholder, .ad {
  background: var(--md-sys-color-surface-container-low);
  border: 2px dashed var(--md-sys-color-outline-variant);
  min-height: 250px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-large-size);
}

/* Lightbox Styles */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
}

.lightbox.open {
  display: flex;
}

.lb-stage {
  position: relative;
  max-width: 96vw;
  max-height: 90vh;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-level5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1; /* below controls */
}

#lb-image {
  max-width: 100%;
  max-height: 90vh;
  display: block;
  border-radius: 16px;
  object-fit: contain;
}

/* Lightbox counter: bottom-centered overlay */
.lb-counter {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none; /* don't block clicks */
}

/* Fullscreen adjustments */
.lightbox:fullscreen {
  align-items: center;
  justify-content: center;
}
.lightbox:fullscreen .lb-stage {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  pointer-events: none; /* don't block controls */
}
.lightbox:fullscreen .lb-prev,
.lightbox:fullscreen .lb-next,
.lightbox:fullscreen .lb-close,
.lightbox:fullscreen .lb-fullscreen {
  opacity: 0.4; /* more transparent in fullscreen */
}
.lightbox:fullscreen .lb-prev:hover,
.lightbox:fullscreen .lb-next:hover,
.lightbox:fullscreen .lb-close:hover,
.lightbox:fullscreen .lb-fullscreen:hover,
.lightbox:fullscreen .lb-prev:focus-visible,
.lightbox:fullscreen .lb-next:focus-visible,
.lightbox:fullscreen .lb-close:focus-visible,
.lightbox:fullscreen .lb-fullscreen:focus-visible,
.lightbox:fullscreen .lb-prev:active,
.lightbox:fullscreen .lb-next:active,
.lightbox:fullscreen .lb-close:active,
.lightbox:fullscreen .lb-fullscreen:active {
  opacity: 0.7; /* do not go fully opaque on interaction */
}
.lightbox:fullscreen #lb-image {
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
  pointer-events: none; /* don't block controls */
}

/* Safari/WebKit fullscreen fallbacks */
.lightbox:-webkit-full-screen {
  align-items: center;
  justify-content: center;
}
.lightbox:-webkit-full-screen .lb-stage {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}
.lightbox:-webkit-full-screen .lb-prev,
.lightbox:-webkit-full-screen .lb-next,
.lightbox:-webkit-full-screen .lb-close,
.lightbox:-webkit-full-screen .lb-fullscreen {
  opacity: 0.4; /* mirror standard fullscreen transparency */
}
.lightbox:-webkit-full-screen .lb-prev:hover,
.lightbox:-webkit-full-screen .lb-next:hover,
.lightbox:-webkit-full-screen .lb-close:hover,
.lightbox:-webkit-full-screen .lb-fullscreen:hover,
.lightbox:-webkit-full-screen .lb-prev:focus-visible,
.lightbox:-webkit-full-screen .lb-next:focus-visible,
.lightbox:-webkit-full-screen .lb-close:focus-visible,
.lightbox:-webkit-full-screen .lb-fullscreen:focus-visible,
.lightbox:-webkit-full-screen .lb-prev:active,
.lightbox:-webkit-full-screen .lb-next:active,
.lightbox:-webkit-full-screen .lb-close:active,
.lightbox:-webkit-full-screen .lb-fullscreen:active {
  opacity: 0.7;
}
.lightbox:-webkit-full-screen #lb-image {
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
}

.lb-prev, .lb-next, .lb-close, .lb-fullscreen {
  position: absolute;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: 0;
  font-size: 24px;
  line-height: 1;
  padding: 12px;
  border-radius: 50%;
  cursor: pointer;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.2, 0.0, 0, 1.0);
  box-shadow: var(--md-sys-elevation-level2);
  z-index: 2; /* above stage */
  pointer-events: auto;
}

.lb-prev:hover, .lb-next:hover, .lb-close:hover, .lb-fullscreen:hover {
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-level3);
  transform: scale(1.05);
}

.lb-close {
  top: 16px;
  right: 16px;
}

.lb-fullscreen {
  top: 16px;
  right: 72px; /* place left of close */
}

.lb-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.lb-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.lb-prev:hover, .lb-next:hover {
  transform: translateY(-50%) scale(1.05);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 240px minmax(0, 1fr) 240px;
    gap: 24px;
    padding: 16px;
  }
  
  .left, .right {
    width: 240px;
  }
}

/* Large screens: align side columns with top of gallery cards */
@media (min-width: 901px) {
  .left,
  .right {
    margin-top: 52px; /* approx. section title height (28px) + margin (24px) */
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .left {
    order: 1;
  }
  
  .center {
    order: 0;
  }
  
  .right {
    order: 2;
  }
  
  .ad, .ad-placeholder {
    min-height: 200px;
  }
  
  .grid-3x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .grid-day {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 600px) {
  .site-header {
    padding: 12px 16px;
  }
  
  .site-header h1 {
    font-size: 1.5rem;
  }
  
  .layout {
    padding: 12px;
  }
  
  .left, .right {
    padding: 12px;
    border-radius: 12px;
  }
  
  .grid-3x2 {
    grid-template-columns: 1fr;
  }
  
  .grid-day {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  
  .theme-toggle {
    padding: 8px 12px;
    min-width: 40px;
    min-height: 40px;
  }

  /* Make lightbox stage use full viewport width on small screens */
  .lb-stage {
    max-width: 100vw;
    border-radius: 0;
  }
}

/* Disclaimer Modal (center-only overlay) */
.center { position: relative; overflow: visible; }
.center .disclaimer {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 10;
}
.center .disclaimer.open { display: block; }
.center .disclaimer__backdrop {
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-background);
}
.center .disclaimer__dialog {
  position: relative;
  max-width: 640px;
  margin: 12vh auto 0 auto;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-radius: 16px;
  box-shadow: var(--md-sys-elevation-level5);
  padding: 24px;
}
.center .disclaimer__title {
  margin: 0 0 12px 0;
  font-family: var(--md-sys-typescale-title-large-font);
  font-size: var(--md-sys-typescale-title-large-size);
  font-weight: var(--md-sys-typescale-title-large-weight);
}
.center .disclaimer__text {
  margin: 0 0 16px 0;
  color: var(--md-sys-color-on-surface-variant);
}
.center .disclaimer__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Content warning specific weights (do not affect global scales) */
.center .disclaimer__title { font-weight: 300; }
.center .disclaimer__text { font-weight: 300; }
/* Button inside disclaimer */
.center .disclaimer .btn { font-weight: 300; }

/* When disclaimer is open, suppress tile shadows to prevent side bleed */
.center .disclaimer.open ~ .grid .tile,
.center .disclaimer.open ~ .grid-3x2 .tile,
.center .disclaimer.open ~ .grid-day .tile,
.center .disclaimer.open ~ #gallery .tile {
  box-shadow: none !important;
}

/* Additionally hide grids/galleries when disclaimer is open to eliminate any bleed */
.center .disclaimer.open ~ #gallery,
.center .disclaimer.open ~ .grid,
.center .disclaimer.open ~ .grid-3x2,
.center .disclaimer.open ~ .grid-day {
  visibility: hidden;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  transition: all 0.2s cubic-bezier(0.2, 0.0, 0, 1.0);
}
.btn:hover {
  background: var(--md-sys-color-surface-container-high);
  box-shadow: var(--md-sys-elevation-level1);
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.btn-primary:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
