/* ========================================================================
   Craig Stubing — Portfolio
   Typography from Beta Cell Foundation brand guide.
   Mode-based theming: Photo pages = light, Video pages = dark.
   ======================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
  min-height: 100%;
}

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

button {
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

main p a,
.text-page a,
.contact-page__bio p a {
  color: var(--fg);
  font-weight: 500;
}

main p a:hover,
.text-page a:hover,
.contact-page__bio p a:hover {
  opacity: 0.65;
}

/* ---- Theme tokens ---- */
:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #555555;
  --dim: #888888;
  --line: #e8e8e8;
  --line-strong: #222222;
  --hero-scrim: rgba(255, 255, 255, 0.05);
  --code-bg: #f5f5f5;
  --shadow-color: rgba(0, 0, 0, 0.08);
}

[data-theme='dark'] {
  --bg: #0a0a0a;
  --fg: #ffffff;
  --muted: #b0b0b0;
  --dim: #777777;
  --line: #1f1f1f;
  --line-strong: #ffffff;
  --hero-scrim: rgba(255, 255, 255, 0.05);
  --code-bg: #131313;
  --shadow-color: rgba(0, 0, 0, 0.5);
}

/* Sticky-footer layout — page is always at least as tall as the viewport */
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

/* ---- Typography primitives ---- */
.eyebrow {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

h1,
h2,
h3,
h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--fg);
}

h1 { font-size: clamp(40px, 7vw, 84px); }
h2 { font-size: clamp(28px, 4vw, 44px); font-weight: 700; letter-spacing: -0.015em; }
h3 { font-size: clamp(20px, 2.4vw, 28px); font-weight: 700; letter-spacing: -0.01em; }

p {
  color: var(--muted);
  line-height: 1.7;
}

p strong,
strong {
  color: var(--fg);
  font-weight: 600;
}

/* ---- Layout ---- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

.container--narrow { max-width: 720px; }
.container--wide { max-width: 1480px; }

.section {
  padding: 56px 0 96px;
}

.section--tight {
  padding: 40px 0 64px;
}

@media (max-width: 700px) {
  .container { padding: 0 20px; }
  .section { padding: 40px 0 64px; }
  .section--tight { padding: 32px 0 48px; }
}

/* ========================================================================
   Header / Navigation
   ======================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  /* Larger logo (42px) needs more breathing room */
  padding: 22px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  border-bottom: 1px solid transparent;
  color: var(--fg);
}

.site-header > .brand { justify-self: start; }
.site-header > .mode-toggle { justify-self: center; }
.site-header > .contact-cta { justify-self: end; }

.site-header--solid {
  background: var(--bg);
  border-bottom-color: var(--line);
}

/* Over the hero in DARK mode (video pages), force white text. In light mode
 * the header keeps its default styling — same logo, same buttons, same
 * colors regardless of scroll position. */
[data-theme='dark'] .site-header--over-hero,
[data-theme='dark'] .site-header--over-hero .brand,
[data-theme='dark'] .site-header--over-hero .nav-mobile-toggle {
  color: #ffffff;
}

/* ---- Brand (logo image) ---- */
.brand {
  display: inline-flex;
  align-items: center;
  height: 42px;
  text-decoration: none;
}

.brand img {
  display: block;
  height: 100%;
  width: auto;
  /* In dark mode the black logo becomes white via filter — keeps a single
   * source PNG so dimensions never shift between modes / scroll states. */
  transition: filter 0.2s ease;
}

[data-theme='dark'] .brand img {
  filter: invert(1);
}

.brand:hover { opacity: 0.7; }

/* ---- Photo / Video toggle (segmented control) ----
 * Same solid styling in every state — over the hero AND scrolled past it.
 * Translucent backdrops were too hard to read against varied hero imagery. */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--code-bg);
}

.mode-toggle__btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 999px;
  letter-spacing: 0.01em;
  transition: opacity 0.15s ease, color 0.18s ease, background 0.18s ease;
}

.mode-toggle__btn:hover { color: var(--fg); opacity: 0.85; }

/* Active pill: theme foreground bg, theme background text.
 *   Photo (light theme) → black pill, white text
 *   Video (dark theme)  → white pill, black text  ← Video button when active */
.mode-toggle__btn--active,
.mode-toggle__btn--active:hover {
  background: var(--fg);
  color: var(--bg);
  opacity: 1;
}

/* ---- About button (rounded rectangle) ---- */
.contact-cta {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  background: var(--fg);
  color: var(--bg);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--fg);
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.05s ease, background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.contact-cta:hover { opacity: 0.85; }
.contact-cta:active { transform: translateY(1px); }

@media (max-width: 760px) {
  /* Same desktop layout — logo left, toggle centered, About right —
   * just everything tighter so it fits on phones. */
  .site-header {
    padding: 14px 16px;
    gap: 12px;
    grid-template-columns: 1fr auto 1fr;
  }
  .brand { height: 30px; }
  .mode-toggle { padding: 3px; gap: 2px; }
  .mode-toggle__btn { padding: 7px 14px; font-size: 12px; }
  .contact-cta { padding: 8px 14px; font-size: 13px; }
}

@media (max-width: 380px) {
  /* Very narrow phones (iPhone SE etc.) — squeeze further */
  .site-header { padding: 12px 10px; gap: 8px; }
  .brand { height: 26px; }
  .mode-toggle__btn { padding: 6px 10px; font-size: 11px; }
  .contact-cta { padding: 7px 10px; font-size: 12px; }
}

/* ========================================================================
   Hero
   ======================================================================== */
.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: flex-end;
  color: #ffffff;
  overflow: hidden;
  background: #000;
}

.hero__media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 1.4s ease-in-out;
  will-change: opacity;
  display: block;
}

.hero__img--active {
  opacity: 1;
}

/* Cut mode (video hero): no fade, instant switch via display.
 * Inactive GIFs are display:none so they don't run animations in the
 * background — when JS makes one --active and resets its src, it plays
 * from frame 1, then we advance again. */
.hero__media--cut .hero__img {
  opacity: 1;
  transition: none;
  display: none;
}

.hero__media--cut .hero__img--active {
  display: block;
}

.hero__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--hero-scrim);
}

.hero__inner {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0 32px 88px;
  max-width: 1280px;
  margin: 0 auto;
}

/* Drop shadow on every hero text element so they read clearly across
 * varied light/dark hero imagery without needing per-image scrim adjustments. */
.hero__eyebrow,
.hero__title,
.hero__tagline {
  text-shadow:
    0 2px 24px rgba(0, 0, 0, 0.45),
    0 1px 3px rgba(0, 0, 0, 0.35);
}

.hero__eyebrow {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 24px;
}

.hero__title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: clamp(48px, 9vw, 112px);
  line-height: 0.95;
  letter-spacing: -0.025em;
  color: #ffffff;
  margin-bottom: 22px;
  max-width: 14ch;
}

.hero__tagline {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(16px, 1.6vw, 20px);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.96);
  max-width: 48ch;
}

@media (max-width: 700px) {
  .hero__inner { padding: 0 20px 64px; }
  .hero__eyebrow { letter-spacing: 0.14em; }
}

/* ========================================================================
   Filter pills (photo home)
   ======================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.filter-bar__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter:hover { border-color: var(--fg); }

.filter--active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.filter-bar__spacer { flex: 1; }

.filter-bar__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  padding: 8px 0;
}

.filter-bar__link:hover { opacity: 0.6; }

@media (max-width: 700px) {
  .filter-bar { padding: 24px 0 20px; }
  .filter-bar__spacer { display: none; }
  .filter-bar__link { margin-top: 8px; width: 100%; }
}

/* ========================================================================
   Card grid (project list, video gallery)
   ======================================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

@media (max-width: 900px) { .card-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; } }
@media (max-width: 560px) { .card-grid { grid-template-columns: 1fr; } }

.gcard {
  display: block;
  color: var(--fg);
}

.gcard__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--code-bg);
  border-radius: 4px;
  margin-bottom: 16px;
}

.gcard__media img,
.gcard__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.3s ease;
}

.gcard:hover .gcard__media img,
.gcard:hover .gcard__media video {
  filter: brightness(1.18);
}

.gcard__title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.005em;
  line-height: 1.2;
  color: var(--fg);
  margin-bottom: 6px;
}

.gcard__meta {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
  margin-bottom: 6px;
}

.gcard__desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.55;
}

/* ========================================================================
   Masonry photo gallery
   ======================================================================== */
.gallery {
  column-count: 3;
  column-gap: 16px;
}

@media (max-width: 900px) { .gallery { column-count: 2; column-gap: 12px; } }
@media (max-width: 520px) { .gallery { column-count: 1; } }

.gallery__item {
  break-inside: avoid;
  margin-bottom: 16px;
  background: var(--code-bg);
  cursor: zoom-in;
  border-radius: 2px;
  overflow: hidden;
  display: block;
  width: 100%;
}

.gallery__item.is-hidden { display: none; }

.gallery__item img {
  width: 100%;
  height: auto;
  display: block;
  transition: filter 0.2s ease;
}

.gallery__item:hover img { filter: brightness(1.12); }

@media (max-width: 900px) { .gallery__item { margin-bottom: 12px; } }

/* ========================================================================
   Lightbox
   ======================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.94);
  padding: 56px 24px;
  cursor: zoom-out;
}

.lightbox--open { display: flex; }

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: default;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox__btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease;
}

.lightbox__btn:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox__btn--prev { left: 16px; }
.lightbox__btn--next { right: 16px; }

.lightbox__close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease;
}

.lightbox__close:hover { background: rgba(255, 255, 255, 0.18); }

.lightbox__counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

/* ========================================================================
   Detail pages
   ======================================================================== */
.detail {
  padding: 140px 0 64px;
}

.back-link,
.back-link-js {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 32px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.back-link:hover,
.back-link-js:hover { color: var(--fg); }

.back-link svg,
.back-link-js svg { width: 14px; height: 14px; }

.detail__head {
  margin-bottom: 36px;
  max-width: 760px;
}

.detail__title {
  margin-bottom: 14px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1;
}

.detail__role {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg);
  margin-bottom: 14px;
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.detail__desc {
  font-size: 17px;
  color: var(--muted);
  max-width: 56ch;
  line-height: 1.65;
}

.detail__media { margin-top: 16px; }

.detail__video,
.detail__embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: block;
  border: 0;
}

/* Multi-clip selector — appears below the player when a video page has
 * multiple clips (e.g. omnipod's 6 commercials). Clicking a thumbnail
 * loads that clip into the main player. */
.video-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.video-selector__item {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--code-bg);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  border: 2px solid transparent;
  transition: border-color 0.18s ease, transform 0.05s ease;
}

.video-selector__item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.2s ease;
}

.video-selector__item:hover img {
  filter: brightness(1.15);
}

.video-selector__item:active {
  transform: translateY(1px);
}

.video-selector__item.is-active {
  border-color: var(--fg);
}

.video-selector__item.is-active::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--bg);
  pointer-events: none;
}

/* Click-to-load facade for YouTube / Vimeo embeds */
.video-facade {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  overflow: hidden;
  display: block;
}

.video-facade__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.25s ease;
}

.video-facade:hover .video-facade__poster { filter: brightness(0.85); }

.video-facade__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.18s ease, transform 0.18s ease;
}

.video-facade:hover .video-facade__play,
.video-facade:focus-visible .video-facade__play {
  background: rgba(0, 0, 0, 0.75);
  transform: translate(-50%, -50%) scale(1.06);
}

/* ========================================================================
   Contact page
   ======================================================================== */
.contact-page { padding: 140px 0 64px; }

.contact-page__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 64px;
  align-items: start;
}

@media (max-width: 900px) {
  .contact-page__grid { grid-template-columns: 1fr; gap: 32px; }
}

.contact-page__image img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.contact-page__bio p + p { margin-top: 16px; }

.contact-page__bio .lede {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-bottom: 24px;
}

.contact-links {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.btn:hover { opacity: 0.85; }

.btn--ghost {
  background: transparent;
  color: var(--fg);
}

/* ========================================================================
   Floating scroll-to-top button (bottom-right)
   ======================================================================== */
.scroll-top-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  box-shadow: 0 8px 24px var(--shadow-color);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-top-fab.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-fab:hover { opacity: 0.92; }
.scroll-top-fab svg { width: 18px; height: 18px; }

@media (max-width: 700px) {
  .scroll-top-fab { right: 16px; bottom: 16px; }
}

/* ========================================================================
   Footer — minimal, page-bg color, line above
   ======================================================================== */
.site-footer {
  background: var(--bg);
  color: var(--muted);
  padding: 24px 0;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  margin-top: 64px;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-bottom__copy,
.footer-bottom__legal {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.footer-bottom__legal {
  display: flex;
  gap: 20px;
}

.footer-bottom__legal a {
  color: inherit;
  transition: color 0.15s ease;
}

.footer-bottom__legal a:hover { color: var(--fg); }

/* ========================================================================
   Long-form text page (Privacy / Terms / 404)
   ======================================================================== */
.text-page { padding: 140px 0 64px; }

.text-page h2 {
  margin-top: 48px;
  margin-bottom: 16px;
  font-size: 22px;
}

.text-page p,
.text-page li {
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.7;
}

.text-page ul {
  padding-left: 20px;
  margin-bottom: 16px;
}

.text-page__updated {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  margin-top: 8px;
}

/* ========================================================================
   Visually-hidden
   ======================================================================== */
.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;
}
