/* =============================================
   Sam Feibel — Shared Stylesheet
   ============================================= */


/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f7f7f7;
  --color-text: #000000;
  --color-muted: #999999;
  --color-border: #2a2a2a;
  --color-accent: #8b0000;
  --color-nav-active: #8b0000;
  --color-surface: #161616;

  --font-serif: 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Helvetica Neue', 'Arial', sans-serif;

  --max-width: 1100px;
  --nav-height: 72px;
  --sidebar-width: 260px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 2rem;
  --spacing-lg: 4rem;
  --spacing-xl: 7rem;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

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

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* --- Navigation (fixed left sidebar) --- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  z-index: 100;
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  padding: var(--spacing-lg) var(--spacing-md);
  overflow-y: auto;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-bottom: var(--spacing-lg);
}

.site-title a {
  color: inherit;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.nav-links li a {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.nav-links li a:hover {
  border-bottom-color: var(--color-text);
}

.nav-links li a.active {
  color: var(--color-nav-active);
  border-bottom-color: var(--color-nav-active);
}

/* Nav group: "Madagascar" sub-gallery list, shown when browsing that section */
.nav-sublist-wrap {
  display: none;
}

.nav-sublist-wrap.open {
  display: block;
}

.nav-sublist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  padding-top: var(--spacing-xs);
  padding-left: var(--spacing-sm);
}

.nav-sublist li a {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.nav-sublist li a:hover {
  color: var(--color-text);
  border-bottom-color: var(--color-text);
}

.nav-sublist li a.active {
  color: var(--color-nav-active);
  border-bottom-color: var(--color-nav-active);
}

/* Hamburger (mobile) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--color-text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* --- Content pane offset (accounts for fixed sidebar) --- */
body > main {
  margin-left: var(--sidebar-width);
}

main {
  min-height: 100vh;
}

/* =============================================
   HOME PAGE — masonry photo wall
   ============================================= */
.home-gallery-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 4px;
  padding-top: var(--spacing-lg);
}

.home-gallery-top img {
  width: 100%;
  height: auto;
  display: block;
}

.home-gallery {
  columns: 2;
  column-gap: 4px;
  margin-top: 4px;
}

.home-gallery img {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 4px;
  break-inside: avoid;
}

.home-gallery-top img,
.home-gallery img {
  cursor: pointer;
}

.home-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
}

.home-lightbox.open {
  display: flex;
}

.home-lightbox-img {
  max-width: 90vw;
  max-height: 92vh;
  object-fit: contain;
}

.home-lightbox-zone {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  background: none;
  border: none;
  padding: 0;
}

.home-lightbox-prev { left: 0; cursor: w-resize; }
.home-lightbox-next { right: 0; cursor: e-resize; }

.home-lightbox-close {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 1001;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.home-lightbox-close:hover { opacity: 1; }

@media (max-width: 500px) {
  .home-gallery-top {
    grid-template-columns: 1fr;
  }

  .home-gallery {
    columns: 1;
  }
}

/* =============================================
   ABOUT PAGE
   ============================================= */

/* Two-column layout */
.about-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  max-width: 1170px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  align-items: start;
}

.about-section {
  padding-top: var(--spacing-lg);
  padding-bottom: var(--spacing-xl);
}

.about-inner {
  max-width: none;
  margin: 0;
}

.about-inner h2:not(.cv-section-title) {
  font-family: var(--font-sans);
  font-size: 1.6rem;
  font-weight: normal;
  margin-bottom: var(--spacing-md);
  letter-spacing: 0.02em;
  color: var(--color-accent);
}

/* "About Me" / "Education" / "Work" keep the cv-section-title font,
   just larger and in the accent color — matching the size these headings had before */
.about-inner .cv-section-title {
  font-family: var(--font-sans);
  font-size: 1.6rem;
  font-weight: normal;
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-accent);
}

.about-inner > p {
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
  font-size: 1.05rem;
  line-height: 1.85;
}

/* Education / Work, resume-style two-column section (nested in the left column) */
.resume-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  margin-top: var(--spacing-lg);
}

.edu-list,
.work-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.edu-degree {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  color: var(--color-text);
  line-height: 1.4;
}

.edu-school {
  font-size: 0.88rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

.work-item {
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

.work-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.work-org {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  color: var(--color-text);
  line-height: 1.4;
}

.work-role {
  font-size: 0.88rem;
  font-style: italic;
  color: var(--color-muted);
  margin: 0.3rem 0 0.5rem;
}

.work-desc {
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.7;
}

/* Photo column on Madagascar page */
.madagascar-photo {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.madagascar-photo img {
  width: 100%;
  height: auto;
}

@media (max-width: 900px) {
  .about-layout {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   GALLERY PAGER (fullscreen viewer)
   ============================================= */
.gallery-viewer {
  position: relative;
}

.pager {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: var(--spacing-lg);
}

.pager-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.pager-zone {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  background: none;
  border: none;
  padding: 0;
}

.pager-zone-prev { left: 0; cursor: w-resize; }
.pager-zone-next { right: 0; cursor: e-resize; }

.gallery-viewer.no-caption .pager-caption {
  display: none;
}

.pager-caption {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  pointer-events: none;
}

/* Bottom bar: numbers + grid toggle, fixed so it stays put in both pager and grid view */
.pager-bottom-bar {
  position: fixed;
  bottom: var(--spacing-md);
  left: calc(var(--sidebar-width) + var(--spacing-md));
  right: var(--spacing-md);
  z-index: 10;
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
}

.pager-numbers {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  list-style: none;
  overflow-x: auto;
  flex-shrink: 1;
  min-width: 0;
}

.pager-numbers button {
  font-size: 0.75rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  color: var(--color-muted);
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.pager-numbers button.active {
  color: var(--color-text);
}

.pager-grid-toggle {
  flex-shrink: 0;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: none;
  border: none;
  cursor: pointer;
}

.pager-grid-toggle:hover {
  color: var(--color-text);
}

/* =============================================
   BONES PAGE — continuous scroll story
   ============================================= */
.story-viewer {
  display: flex;
  flex-direction: column;
}

.story-image {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.story-image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  object-fit: contain;
  cursor: zoom-in;
}

/* Fullscreen mode: hide sidebar, let the story column fill the viewport */
body.story-fullscreen .site-nav {
  display: none;
}

body.story-fullscreen > main {
  margin-left: 0;
}

body.story-fullscreen .story-image {
  height: 115vh;
  padding: 0 var(--spacing-lg);
}

body.story-fullscreen .story-image img {
  cursor: zoom-out;
}

.story-fullscreen-close {
  display: none;
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 200;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  padding: 0.25rem 0.5rem;
}

.story-fullscreen-close:hover {
  opacity: 1;
}

body.story-fullscreen .story-fullscreen-close {
  display: block;
}

.gallery-grid-view {
  display: none;
  padding: var(--spacing-xl) var(--spacing-md);
}

.gallery-viewer.view-grid .pager {
  display: none;
}

.gallery-viewer.view-grid .gallery-grid-view {
  display: block;
}

.gallery-grid {
  columns: 3;
  column-gap: 10px;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 10px;
  background: var(--color-surface);
  position: relative;
  cursor: zoom-in;
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-item .caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.45));
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover .caption {
  opacity: 1;
}

/* Placeholder images */
.placeholder-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-surface);
}

.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: var(--color-surface);
}

/* =============================================
   JOURNAL / PUBLICATIONS PAGE
   ============================================= */
.journal-placeholder {
  text-align: center;
  padding: var(--spacing-xl) 0;
}

/* --- Academic CV layout --- */
.cv-section {
  max-width: 860px;
  margin: 0 auto;
  padding-bottom: var(--spacing-xl);
}

/* Publications column on About page */
.about-layout .cv-section {
  max-width: none;
  padding-bottom: 0;
}

.cv-section-title {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--spacing-md);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

.pub-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pub-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--spacing-md);
  padding: var(--spacing-lg) 0;
  border-bottom: 1px solid var(--color-border);
  align-items: start;
}

.pub-item:first-child {
  padding-top: 0;
}

/* Thumbnail */
.pub-thumb-wrap {
  flex-shrink: 0;
}

.pub-thumb {
  display: block;
  width: 110px;
  aspect-ratio: 17 / 22;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--color-border);
  cursor: zoom-in;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  background: var(--color-surface);
}

.pub-thumb:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

/* Web Applications thumbnails: screenshots, so landscape rather than the
   portrait PDF-page aspect ratio used by .pub-thumb */
.webapp-thumb {
  display: block;
  width: 110px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  background: var(--color-surface);
}

.webapp-thumb:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

/* Text block */
.pub-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pub-authors {
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.5;
}

.pub-authors strong {
  font-weight: 600;
}

.pub-year {
  font-size: 0.88rem;
  color: var(--color-text);
}

.pub-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: normal;
  line-height: 1.4;
  color: var(--color-text);
}

.pub-title a {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1px;
  transition: border-color 0.2s ease;
}

.pub-title a:hover {
  border-color: var(--color-text);
}

.pub-venue {
  font-size: 0.88rem;
  color: var(--color-muted);
  font-style: italic;
  line-height: 1.5;
}

.pub-venue em {
  font-style: normal;
  font-weight: 600;
  color: var(--color-text);
  font-style: italic;
}

.pub-links {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.pub-link {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.pub-link:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

/* PDF lightbox */
.pdf-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.88);
  align-items: center;
  justify-content: center;
}

.pdf-overlay.open {
  display: flex;
}

.pdf-frame {
  width: min(860px, 92vw);
  height: 90vh;
  border: none;
  background: #fff;
}

.pdf-overlay-close {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  padding: 0.25rem 0.5rem;
}

.pdf-overlay-close:hover { opacity: 1; }

@media (max-width: 600px) {
  .pub-item {
    grid-template-columns: 80px 1fr;
    gap: var(--spacing-sm);
  }

  .pub-thumb {
    width: 80px;
  }

  .webapp-thumb {
    width: 80px;
  }
}

/* =============================================
   GARDEN PAGE — Season Timeline
   ============================================= */
.garden-section {
  padding-bottom: var(--spacing-xl);
}

.garden-intro {
  max-width: 620px;
  margin: 0 auto var(--spacing-xl);
  text-align: center;
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1.8;
}

.timeline-section {
  margin-bottom: var(--spacing-xl);
}

.timeline-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.timeline-label::before,
.timeline-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* =============================================
   CONTACT PAGE
   ============================================= */
.contact-section {
  padding-top: var(--spacing-lg);
  padding-bottom: var(--spacing-xl);
}

.contact-inner {
  max-width: 640px;
  margin: 0 auto 0 0;
}

.contact-photo img {
  width: 100%;
  height: auto;
  margin-bottom: var(--spacing-lg);
}

.contact-inner p {
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.contact-list li {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contact-list .label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.contact-list .value {
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

.contact-list .value a {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1px;
  transition: border-color 0.2s ease;
}

.contact-list .value a:hover {
  border-color: var(--color-text);
}

/* =============================================
   MAP PAGE
   ============================================= */
.map-section {
  padding: var(--spacing-lg) 0 var(--spacing-lg);
}

.map-section .container {
  max-width: 1170px;
}

#map {
  width: 100%;
  height: calc(100vh - 2 * var(--spacing-lg));
  min-height: 500px;
  margin: 0 auto;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  :root {
    --spacing-lg: 3rem;
    --spacing-xl: 4.5rem;
  }

  /* Nav mobile: sidebar collapses to a top bar + dropdown */
  .site-nav {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: var(--nav-height);
    padding: 0 var(--spacing-md);
    overflow-y: visible;
  }

  .site-title {
    margin-bottom: 0;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-md);
    gap: var(--spacing-md);
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-links li a {
    font-size: 0.9rem;
  }

  body > main {
    margin-left: 0;
    padding-top: var(--nav-height);
  }

  body.story-fullscreen > main {
    padding-top: 0;
  }

  .pager-bottom-bar {
    left: var(--spacing-md);
  }

}

@media (max-width: 600px) {
  .gallery-grid {
    columns: 2;
  }
}

@media (max-width: 400px) {
  .gallery-grid {
    columns: 1;
  }
}
