/* ============================================================
   RESET & BOX MODEL
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================================
   CSS CUSTOM PROPERTIES (design tokens)
   Single source of truth for colors, type scale, spacing, layout.
   ============================================================ */
:root {
  /* Colors */
  --color-bg:     #0d2137;
  --color-text:   #f0ede6;
  --color-accent: #f43f5e;

  /* Section text colour – updated per section by JS */
  --section-text: #f0ede6;

  /* Typography */
  --font-body: 'Ubuntu', sans-serif;

  /* Type scale – relative to root font-size set on html below */
  --size-sm: 0.875rem;  /* captions, footer */
  --size-md: 1rem;      /* body text */
  --size-lg: 1.25rem;   /* site title, lead text */
  --size-h3: 1.375rem;
  --size-h2: 1.75rem;
  --size-h1: 2.25rem;

  --line-height:         1.6;
  --line-height-heading: 1.2;

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 3rem;
  --space-xxxl: 7rem;

  /* Layout */
  --header-height: 5rem;
}

/* ============================================================
   BASE – body defaults, heading scale
   ============================================================ */
html {
  scroll-behavior: smooth;
  overflow-y: scroll;
  height: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--size-md);
  line-height: var(--line-height);
  height: 100%;
}

/* Heading defaults */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-heading);
  font-weight: 700;
}
h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }

/* Links default color */
a {
  color: var(--color-accent);
}

/* ============================================================
   CONTENT WRAPPER
   ============================================================ */
main {
  width: 100%;
  padding: 0;
  max-width: 100%;
  margin: 0;
}

/* ============================================================
   STICKY HEADER
   ============================================================ */
#site-header {
  position: fixed;
  top: 0;
  z-index: 100;
  width: 100%;

  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  min-height: var(--header-height);

  color: var(--section-text);
  transition: color 0.35s ease;
}

.site-title {
  color: inherit;
  text-decoration: none;
  font-size: var(--size-h2);
  font-weight: 700;
}

/* ============================================================
   NAVIGATION – desktop (inline row)
   ============================================================ */
#main-nav {
  display: flex;
  align-items: center;
}

/* Nav list items in a horizontal row on desktop */
#nav-list {
  display: flex;
  gap: var(--space-md);
  list-style: none;
}

#nav-list a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, font-size 0.2s ease;
}

#nav-list a.active {
  color: var(--color-accent);
  font-weight: 700;
  font-size: 1.05rem;
}

/* Hamburger button hidden on desktop */
#hamburger {
  display: none;
}

/* ============================================================
   FULL-SCREEN SNAP SECTIONS
   ============================================================ */
main > section {
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   FOOTER (inside #contact)
   ============================================================ */
#contact > footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-sm);
  text-align: center;
  font-size: var(--size-sm);
  opacity: 0.5;
  border-top: 0.0625rem solid color-mix(in srgb, var(--section-text) 20%, transparent);
}

/* ============================================================
   HORIZONTAL TRACK (sections with sub-sections)
   ============================================================ */
.section-track {
  display: flex;
  height: calc(100% - 0.375rem); /* leave room for progress bar */
  overflow-x: scroll;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

/* Individual panels inside a track */
.section-panel {
  height: 100%;
  flex-shrink: 0;
  overflow-y: auto;
  padding: calc(var(--header-height) + var(--space-lg)) var(--space-xxxl) var(--space-lg);
  background-color: var(--section-bg);
  color: var(--section-text);
  will-change: transform;
  transition: transform 0.07s linear;
}

.section-panel a {
  color: var(--section-accent);
}

.section-panel > h3 {
  margin-bottom: var(--space-sm);
}

.section-panel > p {
  margin-bottom: var(--space-xs);
}

.section-panel > p:last-child {
  margin-bottom: 0;
}

/* Title-only intro panel */
.section-intro {
  min-width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-sm);
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.section-intro h1 {
  font-size: clamp(3rem, 8vw, 6rem);
}

.scroll-hint {
  font-size: var(--size-md);
  opacity: 0.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Single-panel sections – vertically centred */
.section-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-sm);
  height: 100%;
  padding: calc(var(--header-height) + var(--space-lg)) var(--space-lg) var(--space-lg);
  overflow-y: auto;
}

.section-content p {
  margin-bottom: var(--space-xs);
}

.section-content p:last-child {
  margin-bottom: 0;
}

/* Progress bar */
.section-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0.375rem;
  background: color-mix(in srgb, var(--section-text) 15%, transparent);
  z-index: 10;
}

.section-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--section-accent);
  transition: width 0.1s linear;
}

/* ============================================================
   SECTION COLOR THEMES – alternating, driven by root tokens
   ============================================================ */
main > section:nth-child(odd) {
  --section-bg:     var(--color-bg);
  --section-text:   var(--color-text);
  --section-accent: var(--color-accent);
  background-color: var(--section-bg);
  color: var(--section-text);
}

main > section:nth-child(even) {
  --section-bg:     var(--color-text);
  --section-text:   var(--color-bg);
  --section-accent: var(--color-accent);
  background-color: var(--section-bg);
  color: var(--section-text);
}

/* Scope link colors to accent per section */
main > section a {
  color: var(--section-accent);
}

main > section a:hover {
  opacity: 0.8;
}

/* GitHub repo link – override general link color, use section text instead */
main > section a.github-link {
  color: var(--section-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: color 0.2s ease, transform 0.2s ease;
}

main > section a.github-link:hover {
  color: var(--color-accent);
  transform: scale(1.2);
  opacity: 1;
}

/* ============================================================
   MEDIA PANELS – column-wrap flow layout (projects & hobbies)
   Items stack vertically; overflow wraps into a new column.
   Each column is only as wide as its widest element.
   ============================================================ */
.media-panel {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: var(--space-sm) var(--space-md);
  overflow-x: auto;
  overflow-y: hidden;
}

.panel-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.panel-info > h2 {
  font-size: clamp(2.5rem, 4.5vw, 4rem);
  line-height: var(--line-height-heading);
  margin-bottom: 0;
}

.tech-icons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: center;
}

/* SVG icon images */
.tech-icon {
  width: 2rem;
  height: 2rem;
}

/* Font Awesome fallback icons (e.g. Google Sheets) */
.tech-icons i {
  font-size: 2rem;
  line-height: 1;
}

/* GitHub repo link styling (color handled by scoped link rules below) */
.tech-icons .github-link:first-of-type {
  margin-left: auto;
}

.tech-icons .github-link {
  font-size: 2rem;
  line-height: 1;
}

.panel-info > p {
  max-width: 55ch;
  margin-bottom: 0;
}

/* Media elements as direct children of the panel */
.media-panel > img {
  height: auto;
  max-height: 42vh;
  width: auto;
  max-width: 50vw;
  border-radius: 0.5rem;
  cursor: zoom-in;
  flex-shrink: 0;
  display: block;
}

.media-panel > video {
  max-height: 30vh;
  width: auto;
  max-width: 50vw;
  border-radius: 0.5rem;
  display: block;
  flex-shrink: 0;
}

.proj-media-placeholder {
  width: 20rem;
  min-height: 12rem;
  border-radius: 0.5rem;
  border: 0.125rem dashed color-mix(in srgb, var(--section-text) 25%, transparent);
  background: color-mix(in srgb, var(--section-text) 5%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  flex-shrink: 0;
}

.proj-media-placeholder .placeholder-text {
  text-align: center;
  font-size: 0.875rem;
  color: color-mix(in srgb, var(--section-text) 60%, transparent);
  line-height: var(--line-height);
  word-wrap: break-word;
  max-width: 100%;
}

/* ============================================================
   SECTION NAV BUTTONS (prev / next vertical section)
   ============================================================ */
.section-nav-btn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 201;
  background: color-mix(in srgb, var(--section-text) 12%, transparent);
  border: 0.0625rem solid color-mix(in srgb, var(--section-text) 25%, transparent);
  color: var(--section-text);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.35s ease;
  backdrop-filter: blur(4px);
}

.section-nav-btn:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--section-text) 22%, transparent);
}

.section-nav-btn:disabled {
  opacity: 0;
  pointer-events: none;
}

#scroll-up-btn {
  top: var(--space-md);
  /* transform is overridden to keep translateX(-50%) in place */
  transform: translateX(-50%);
}

#scroll-down-btn {
  bottom: var(--space-sm);
  transform: translateX(-50%);
}

/* Lightbox overlay */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#lightbox.open {
  display: flex;
}

#lightbox > img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 0.25rem;
  box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
}

/* ============================================================
   RESPONSIVE – hamburger menu at <= 48em (≈768px)
   Using em for media queries is best practice: zoom-resilient and
   independent of root font-size overrides.
   ============================================================ */
@media (max-width: 48em) {

  /* Show hamburger button */
  #hamburger {
    display: flex;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: white;
    font-size: 1.4rem;
  }

  /* Nav list hidden by default on mobile */
  #nav-list {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    min-width: 12rem;
    flex-direction: column;
    gap: 0;
    background-color: var(--color-bg);
    border-bottom: 0.0625rem solid color-mix(in srgb, var(--color-text) 20%, transparent);
    padding: var(--space-xs) 0;
    list-style: none;
    z-index: 200;
  }

  /* Nav list visible when .open is toggled by JS */
  #nav-list.open {
    display: flex;
  }

  #nav-list li a {
    display: block;
    padding: 0.75rem var(--space-sm);
  }

  /* ── Disable custom scroll layout on mobile ── */
  html {
    overflow-y: auto;
    height: auto;
  }

  body {
    height: auto;
  }

  #site-header {
    position: sticky;
    background-color: var(--color-bg);
    border-bottom: 0.0625rem solid color-mix(in srgb, var(--color-text) 20%, transparent);
    padding: var(--space-xs) var(--space-sm);
    min-height: 3.5rem;
  }

  /* Keep nav link text legible over the fixed dark mobile header */
  #nav-list a {
    color: var(--color-text);
  }

  main > section {
    height: auto;
    overflow: visible;
    scroll-margin-top: 3.5rem;
  }

  .section-content {
    display: block;
    height: auto;
    padding: var(--space-lg) var(--space-sm) var(--space-lg);
  }

  .section-track {
    display: block;
    overflow-x: visible;
    height: auto;
  }

  .section-panel {
    min-width: 100%;
    width: 100%;
    height: auto;
    overflow-y: visible;
    padding: var(--space-lg) var(--space-sm);
  }

  .section-intro {
    display: block;
    text-align: left;
    padding: var(--space-lg) var(--space-sm) var(--space-sm);
  }

  .section-intro h2 {
    font-size: var(--size-h2);
  }

  .scroll-hint {
    display: none;
  }

  .section-progress {
    display: none;
  }

  .section-nav-btn {
    display: none;
  }

  #contact > footer {
    position: static;
    border-top: 0.0625rem solid var(--color-border);
    margin-top: var(--space-md);
  }

  .media-panel {
    overflow-x: hidden;
    overflow-y: auto;
    flex-wrap: nowrap;
  }

  .media-panel > img,
  .media-panel > video {
    max-width: 100%;
    width: 100%;
    max-height: none;
  }

  .panel-info > h2 {
    font-size: var(--size-h3);
  }
}