/* =============================================================================
   style.css — Nicky Rhodes Portfolio
   =============================================================================

   Sections:
   1.  Reset & Base
   2.  Typography
   3.  Persistent Name Element
   4.  Landing View — Bio
   5.  Landing View — Learn More Links
   6.  Landing View — Carousel Container
   7.  Landing View — Carousel Items
   8.  Landing View — Carousel Arrows
   9.  Project View — Structure
   10. Project View — Left Text Panel
   11. Project View — Image Column
   12. View Transition States
   13. Responsive — Mobile (max-width: 768px)
   ============================================================================= */

/* =============================================================================
   1. Reset & Base
   ============================================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-synthesis: none; /* prevent browser from synthesizing bold/italic */
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #ffffff;
  /* background-color: #f5f5f5; */
}

body {
  overflow-x: hidden;
  font-family: "Roboto", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: #111;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Button reset — used for name element and arrow buttons */
button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
}

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

/* =============================================================================
   2. Typography
   ============================================================================= */

/* No global typography rules beyond what's in body — everything is controlled
   per-component below. */

/* =============================================================================
   3. Persistent Name Element
   =============================================================================

   #nicky-rhodes-name sits outside both view containers, fixed to the top-left
   of the viewport. It never moves between views — only its weight, cursor,
   and interactivity change.

   Landing view: bold, default cursor, not a meaningful button (aria-label present
   but functionally inert).
   Project view (.project-mode): regular weight, pointer cursor, clickable.
   ============================================================================= */

#nicky-rhodes-name {
  position: fixed;
  top: 0;
  left: 0;
  padding-top: 28px;
  padding-left: 28px;
  font-size: 25px;
  font-weight: 400;
  line-height: 1.45;
  z-index: 100;
  cursor: default;
  user-select: none;
  outline: none;
  /* Hidden in landing view — the bio paragraph renders "Nicky Rhodes" there */
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

#nicky-rhodes-name:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

/* Project mode — applied by JS when entering project view */
#nicky-rhodes-name.project-mode {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
  font-weight: 400;
  -webkit-text-stroke-width: 0px;
  transition:
    opacity 300ms ease,
    -webkit-text-stroke-width 150ms ease;
}

#nicky-rhodes-name.project-mode:hover,
#nicky-rhodes-name.project-mode.clicking {
  -webkit-text-stroke-width: 1px;
}

/* =============================================================================
   4. Landing View — Bio
   ============================================================================= */

#landing {
  position: fixed;
  inset: 0;
  /* Opacity controlled via .hidden class below */
  transition: opacity 300ms ease;
}

#bio {
  position: absolute;
  top: 28px;
  left: 28px;
}

#bio-text {
  font-size: 25px;
  font-weight: 400;
  line-height: 1.45;
  /*
    max-width constrains the text so "researcher" is the last word on line 1
    at typical desktop widths. "Nicky Rhodes is a designer, builder, and researcher"
    is ~46 characters. Adjust if bio copy changes.
  */
  max-width: 40ch;
  transition: opacity 300ms ease;
}

.bolded {
  font-weight: 400; /* override browser default bold for <strong> */
  -webkit-text-stroke-width: 1px;
}

/* On mobile, relax the max-width constraint and let text flow naturally */
/* (see responsive section) */

/* =============================================================================
   5. Landing View — Learn More Links
   =============================================================================

   "Resume,  Contact" — separated by a literal comma + non-breaking space.
   Both links use border-bottom (not text-decoration) for controllable thickness.

   The padding-bottom compensation trick prevents layout shift when transitioning
   border-bottom-width: total = padding-bottom + border-bottom-width = constant 3px.
   ============================================================================= */

#learn-more {
  display: flex;
  align-items: baseline;
  margin-top: 22px;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.45;
  transition: opacity 300ms ease;
}

#resume-link,
#contact-trigger {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px; /* 1 + 2 = 3px total — stays constant on hover */
  cursor: pointer;
  line-height: 1;
  transition:
    border-bottom-width 150ms ease,
    padding-bottom 150ms ease;
}

#resume-link:hover,
#contact-trigger:hover {
  border-bottom-width: 2px;
  padding-bottom: 1px; /* 2 + 1 = 3px total */
}

#resume-link:focus-visible,
#contact-trigger:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

/* =============================================================================
   6. Landing View — Carousel Container
   ============================================================================= */

#carousel-zone {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  /* Height is determined by its content (thumbnails + title row) */
  transition: opacity 300ms ease;
}

#carousel-track {
  display: flex;
  flex-direction: row;
  align-items: flex-end; /* align bottoms so title rows line up */
  gap: 28px;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  /* .no-snap added by JS during drag so CSS snap doesn't fire on release */
  -ms-overflow-style: none; /* IE/Edge */
  scrollbar-width: none; /* Firefox */
  padding: 0 28px 24px 28px;
  scroll-padding-left: 28px; /* snap alignment must match padding-left */
  width: 100%;
  /* scroll-behavior: smooth is set per-call in JS to avoid interfering with drag */
}

#carousel-track.no-snap {
  scroll-snap-type: none;
}

#carousel-track::-webkit-scrollbar {
  display: none;
}

/* =============================================================================
   7. Landing View — Carousel Items
   ============================================================================= */

.carousel-item {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
}

/* Desktop: fixed height, variable width (natural aspect ratio) */
.carousel-thumb {
  height: 360px;
  width: auto;
  display: block;
  object-fit: cover;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0); /* start transparent for transition */
  transition: box-shadow 200ms ease;
}

.carousel-item:hover .carousel-thumb {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Reserved title row — always present (prevents layout shift on hover).
   Height is always occupied even when text is invisible. */
.carousel-title {
  height: 1.5em;
  margin-top: 8px;
  font-size: 17px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 200ms ease;
}

.carousel-item:hover .carousel-title {
  opacity: 1;
}

/* External link indicator (optional visual treatment) */
.carousel-item[data-external] .carousel-thumb {
  /* No special treatment needed — hover behavior is identical per spec */
}

/* =============================================================================
   8. Landing View — Carousel Arrows
   ============================================================================= */

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(
    calc(-50% - 12px)
  ); /* -12px adjusts for title row below center */
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.92);
  outline: none;
}

.carousel-arrow:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

#carousel-arrow-left {
  left: 4px;
}

#carousel-arrow-right {
  right: 4px;
}

/* Arrows appear when cursor is anywhere in the carousel zone */
#carousel-zone.arrows-visible .carousel-arrow {
  opacity: 1;
  pointer-events: auto;
}

/* Individual arrow hidden at boundary positions */
.carousel-arrow.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Arrow icon — translates a few pixels on hover */
.carousel-arrow .arrow-icon {
  display: block;
  transition: transform 150ms ease;
}

#carousel-arrow-left:hover .arrow-icon {
  transform: translateX(-4px);
}

#carousel-arrow-right:hover .arrow-icon {
  transform: translateX(4px);
}

/* =============================================================================
   9. Project View — Structure
   ============================================================================= */

#project {
  position: fixed;
  inset: 0;
  /* Initially hidden */
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

#project.visible {
  opacity: 1;
  pointer-events: auto;
}

/* =============================================================================
   10. Project View — Left Text Panel (desktop)
   ============================================================================= */

#project-text {
  position: absolute;
  bottom: 28px;
  left: 28px;
  font-size: 25px;
  width: 40ch;
  max-height: calc(100vh - 100px - 56px);
  overflow-y: auto;
}

#project-title {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 12px 0;
}

#project-description {
  font-size: 25px;
  font-weight: 400;
  line-height: 1.45;
  margin: 0 0 12px 0;
}

/* Full description — smaller font, hidden by default; shown via JS toggle */
#project-description-full {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.5;
  margin: 0 0 12px 0;
  display: none;
}

/* Inline "Show more" / "Show less" toggle buttons */
.desc-toggle {
  display: inline;
  font-size: 17px;
  font-weight: 400;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 0px;
  color: currentColor;
  cursor: pointer;
}

#project-links {
  margin-top: 16px;
}

#project-links p {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.45;
  margin: 0 0 4px 0;
}

#project-links a {
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
  transition:
    border-bottom-width 150ms,
    padding-bottom 150ms;
}

#project-links a:hover {
  border-bottom-width: 2px;
  padding-bottom: 1px;
}

/* =============================================================================
   11. Project View — Image Column (desktop)
   ============================================================================= */

#project-images {
  position: absolute;
  top: 0;
  bottom: 0;
  font-size: 25px;
  left: calc(28px + 40ch + 28px);
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 60px 0;
}

.image-item {
  width: 100%;
  margin-bottom: 28px;
}

.image-item:last-child {
  margin-bottom: 0;
}

.image-media {
  display: block;
  width: 100%;
  height: auto;
}

/* 16:9 wrapper for iframe embeds */
.video-wrapper {
  width: 100%;
  aspect-ratio: 16 / 9;
  position: relative;
}

.video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.image-caption {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  margin-top: 8px;
  color: #555;
}

/* Hide mobile-only elements on desktop */
#project-mobile-title,
#project-info-btn,
#project-blur-overlay,
#project-drawer {
  display: none;
}

/* =============================================================================
   12. View Transition States
   =============================================================================

   Classes toggled by JS to drive all fade transitions.
   .hidden = opacity 0 + pointer-events none.
   All transitions are 300ms ease.
   ============================================================================= */

/* Applied to whole #landing when entering project view */
#landing.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Applied to individual sub-elements for staged fade-out */
#bio-text.hidden {
  opacity: 0;
  pointer-events: none;
}

#learn-more.hidden {
  opacity: 0;
  pointer-events: none;
}

#carousel-zone.hidden {
  opacity: 0;
  pointer-events: none;
}

/* =============================================================================
   13. Responsive — Mobile (max-width: 768px)
   ============================================================================= */

@media (max-width: 768px) {
  /* Tighter page margins on mobile */
  #nicky-rhodes-name {
    padding-top: 20px;
    padding-left: 24px; /* must match #bio position for project view overlay */
  }

  #bio {
    top: 20px;
    left: 24px;
  }

  #bio-text {
    max-width: 90vw; /* relax constraint; let text wrap naturally */
  }

  #learn-more {
    margin-top: 18px;
  }

  /* Carousel: fixed width (nearly full viewport), variable height */
  .carousel-thumb {
    height: auto;
    width: calc(100vw - 72px); /* full width minus 2× page margin */
    object-fit: cover;
  }

  /* Title visible for active (snapped) item only */
  .carousel-title {
    opacity: 0;
    transition: opacity 200ms ease;
  }

  .carousel-item.snapped .carousel-title {
    opacity: 1;
  }

  /* No hover title effect on touch devices */
  .carousel-item:hover .carousel-title {
    opacity: 0;
  }

  /* Snapped title hidden — #project-mobile-title shows it persistently */
  .carousel-item.snapped:hover .carousel-title,
  .carousel-item.snapped .carousel-title {
    opacity: 0;
  }

  /* No arrow buttons on mobile */
  .carousel-arrow {
    display: none;
  }

  /* Reduce bleed gap in carousel for mobile */
  #carousel-track {
    padding: 0 24px 24px 24px;
    gap: 16px;
  }

  /* Left text panel hidden on mobile (content is in drawer) */
  #project-text {
    display: none;
  }

  /* Image zone fills full height below name */
  #project-images {
    left: 0;
    top: 0;
    bottom: 0;
    padding: calc(20px + 25px * 1.45 + 16px) 0 0;
  }

  /* Project title button — bottom-left, always visible, opens drawer.
     Lives outside both views (like #nicky-rhodes-name) so it never fades.
     Landing mode: weight 400 (matches carousel title).
     Project mode (.project-mode): weight 700 (bold). */
  #project-mobile-title {
    display: block;
    position: fixed;
    bottom: 24px;
    left: 24px;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.45;
    color: inherit;
    text-align: left;
    z-index: 9;
    max-width: calc(100% - 96px); /* leave room for info button */
    transition: font-weight 300ms ease;
  }

  #project-mobile-title.project-mode {
    font-weight: 700;
    cursor: pointer;
  }

  /* Info button — bottom-right, small, opens drawer */
  #project-info-btn {
    display: block;
    position: absolute;
    bottom: 24px;
    right: 24px;
    font-size: 17px;
    font-weight: 400;
    color: inherit;
    border-bottom: 1px dashed currentColor;
    z-index: 9;
  }

  /* Full-screen blur overlay — fades in behind drawer */
  #project-blur-overlay {
    display: block;
    position: absolute;
    inset: 0;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
    z-index: 8;
  }

  #project-blur-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Slide-up drawer */
  #project-drawer {
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50vh;
    background: #fff;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 300ms ease;
    overflow: hidden;
    z-index: 10;
  }

  #project-drawer.open {
    transform: translateY(0);
  }


  #drawer-body {
    padding: 16px 24px 24px;
    overflow-y: auto;
    flex: 1;
  }

  #drawer-title {
    font-size: 25px;
    font-weight: 700;
    line-height: 1.45;
    margin: 0 0 12px 0;
  }

  #drawer-description {
    font-size: 25px;
    font-weight: 400;
    line-height: 1.45;
    margin: 0 0 12px 0;
  }

  #drawer-description-full {
    font-size: 17px;
    font-weight: 400;
    line-height: 1.5;
    margin: 0 0 12px 0;
    display: none;
  }

  #drawer-links {
    margin-top: 16px;
  }

  #drawer-links p {
    font-size: 17px;
    font-weight: 400;
    line-height: 1.45;
    margin: 0 0 4px 0;
  }

  #drawer-links a {
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid currentColor;
    padding-bottom: 2px;
  }
}
