/* ============================================================
   Josh Stein Portfolio — Design System
   Fonts: Fraunces (display) + Instrument Sans (body)
   ============================================================ */

:root {
  --bg: #F9F6ED;
  --text: #1A1A18;
  --muted: #767672;
  --accent: #C84B2F;
  --surface: #EEECEA;
  --border: #D8D2C8;
  --nav-bg-scrolled: rgba(249, 246, 237, 0.88);
  --nav-menu-bg: rgba(249, 246, 237, 0.98);
  --work-overlay: rgba(26, 26, 24, 0.38);
  --lightbox-overlay: rgba(0, 0, 0, 0.88);
  --lightbox-media-bg: #111110;
  --lightbox-placeholder: rgba(255, 255, 255, 0.15);
  --lightbox-client-text: rgba(255, 255, 255, 0.5);
  --lightbox-text: #FFFFFF;
  --lightbox-muted-text: rgba(255, 255, 255, 0.6);
  --lightbox-counter-text: rgba(255, 255, 255, 0.3);
  --lightbox-control-text: rgba(255, 255, 255, 0.7);
  --lightbox-control-hover: #FFFFFF;
  --lightbox-drag-handle: rgba(255, 255, 255, 0.2);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Instrument Sans', system-ui, sans-serif;
  --max-width: 1200px;
  --section-pad: 96px;
}

:root[data-theme="dark"] {
  --bg: #111110;
  --text: #F3EFE6;
  --muted: #B5B0A6;
  --accent: #D96A4A;
  --surface: #1B1A18;
  --border: #2B2926;
  --nav-bg-scrolled: rgba(17, 17, 16, 0.88);
  --nav-menu-bg: rgba(17, 17, 16, 0.98);
  --work-overlay: rgba(0, 0, 0, 0.42);
  --lightbox-overlay: rgba(0, 0, 0, 0.92);
  --lightbox-media-bg: #0C0C0B;
  --lightbox-placeholder: rgba(243, 239, 230, 0.16);
  --lightbox-client-text: rgba(243, 239, 230, 0.62);
  --lightbox-text: #F3EFE6;
  --lightbox-muted-text: rgba(243, 239, 230, 0.74);
  --lightbox-counter-text: rgba(243, 239, 230, 0.38);
  --lightbox-control-text: rgba(243, 239, 230, 0.76);
  --lightbox-control-hover: #FFF9F0;
  --lightbox-drag-handle: rgba(243, 239, 230, 0.28);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.18s ease-out, color 0.18s ease-out;
}
img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- Nav ---- */
nav {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  padding: 28px 40px;
  display: flex;
  gap: 32px;
  align-items: center;
  transition: background-color 0.3s ease-out, backdrop-filter 0.3s ease-out, border-color 0.3s ease-out;
  border-bottom: 1px solid transparent;
}
nav.nav--scrolled {
  background: var(--nav-bg-scrolled);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}
nav .nav-links {
  display: flex;
  align-items: center;
  gap: 44px;
}
nav a {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  transition: color 0.15s ease-out;
  padding: 14px 0;
  display: inline-flex;
  align-items: center;
  position: relative;
}
nav a::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.2s ease-out;
}
nav a:hover { color: var(--accent); text-decoration: none; }
nav a:hover::after { width: 100%; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  background: none;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 68px;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease-out, border-color 0.18s ease-out, background-color 0.18s ease-out;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border);
}
.theme-toggle[aria-pressed="true"] {
  border-color: var(--border);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 8px;
  min-width: 44px;
  min-height: 44px;
  color: var(--text);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease-out;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: currentColor;
  margin: 5px 0;
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}
nav.nav--menu-open .nav-toggle span:first-child {
  transform: translateY(5.75px) rotate(45deg);
}
nav.nav--menu-open .nav-toggle span:last-child {
  transform: translateY(-5.75px) rotate(-45deg);
}

/* ---- Hero ---- */
#hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 30fr 70fr;
  align-items: stretch;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 40px;
}

.hero-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 120px 60px 80px 0;
}

.hero-name {
  font-family: var(--font-display);
  font-size: clamp(64px, 7vw, 96px);
  font-weight: 900;
  line-height: 0.93;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 28px;
  text-wrap: balance;
}

.hero-title {
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 32px;
  line-height: 1.4;
}

.hero-titles {
  list-style: none;
  margin: 0 0 32px;
  padding: 0;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.5;
}
.hero-titles li {
  display: block;
}

.hero-links {
  display: flex;
  gap: 24px;
  font-size: 15px;
  font-weight: 500;
}
.hero-links a {
  color: var(--accent);
  position: relative;
}
.hero-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.2s ease-out;
}
.hero-links a:hover { text-decoration: none; }
.hero-links a:hover::after { width: 100%; }

.hero-photo {
  position: relative;
  display: flex;
  align-items: flex-end;
}
.hero-photo img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Section base ---- */
section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--section-pad) 40px;
}

.section-heading {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 56px;
  text-wrap: balance;
}

/* ---- Work grid ---- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.work-tile {
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.work-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  background: var(--surface);
  transition: opacity 0.2s ease-out;
}
.work-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease-out;
}
/* Placeholder styling when no real image */
.work-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.4;
  letter-spacing: -0.02em;
}

.work-label {
  padding: 14px 0 2px;
  transition: transform 0.2s ease-out;
}
.work-label .client {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}
.work-label .campaign {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  display: block;
}

.work-thumb::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 24, 0);
  transition: background 0.25s ease-out;
  z-index: 1;
  pointer-events: none;
}
.work-thumb::after {
  content: '▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.75);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  font-family: var(--font-body);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  padding-left: 3px;
  opacity: 0;
  transition: opacity 0.22s ease-out, transform 0.22s ease-out;
  z-index: 2;
  pointer-events: none;
}
.work-tile:hover .work-thumb::before {
  background: var(--work-overlay);
}
.work-tile:hover .work-thumb::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.work-tile:hover .work-thumb { opacity: 1; }
.work-tile:hover .work-thumb img { transform: scale(1.03); }
.work-tile:hover .work-label { transform: translateY(-3px); }
.work-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- About ---- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
}
.about-col p {
  margin-bottom: 20px;
  line-height: 1.7;
  font-size: 17px;
  color: var(--text);
}
.about-col p:last-child { margin-bottom: 0; }

/* ---- Awards ---- */
.awards-intro {
  max-width: 760px;
  margin: 0 0 48px;
}
.awards-intro p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 16px;
}
.awards-intro p:last-child { margin-bottom: 0; }

.awards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 64px;
}
.awards-col {
  display: flex;
  flex-direction: column;
}
.award-item {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
}
.award-detail {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---- Contact ---- */
#contact {
  border-top: 1px solid var(--border);
}
.contact-heading {
  font-family: var(--font-display);
  font-size: clamp(36px, 4vw, 56px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 36px;
  text-wrap: balance;
}
.contact-links {
  display: flex;
  gap: 32px;
  font-size: 16px;
  font-weight: 500;
  flex-wrap: wrap;
}
.contact-links a {
  color: var(--accent);
  padding: 10px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  position: relative;
}
.contact-links a::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.22s ease-out;
}
.contact-links a:hover { text-decoration: none; }
.contact-links a:hover::after { width: 100%; }

footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 40px calc(48px + env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--muted);
}

/* ---- Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: var(--lightbox-overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}
.lightbox-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox-panel {
  position: relative;
  width: 70vw;
  max-width: 70vw;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s ease-out;
}
.lightbox-overlay.open .lightbox-panel {
  transform: translateY(0) scale(1);
}

.lightbox-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--lightbox-media-bg);
  overflow: hidden;
}
.lightbox-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lightbox-media iframe {
  width: 100%;
  height: 100%;
  border: none;
}
.lightbox-media-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--lightbox-placeholder);
  letter-spacing: -0.02em;
}

.lightbox-info {
  padding: 20px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.lightbox-info-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lightbox-client {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lightbox-client-text);
}
.lightbox-campaign {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--lightbox-text);
  letter-spacing: -0.01em;
}
.lightbox-desc {
  font-size: 14px;
  color: var(--lightbox-muted-text);
  line-height: 1.5;
  margin-top: 4px;
}
.lightbox-counter {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--lightbox-counter-text);
  white-space: nowrap;
  padding-top: 4px;
  flex-shrink: 0;
}

.lightbox-close {
  position: absolute;
  top: -52px;
  right: -4px;
  background: none;
  border: none;
  color: var(--lightbox-control-text);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 8px 12px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease-out;
}
.lightbox-close:hover { color: var(--lightbox-control-hover); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--lightbox-control-text);
  font-size: 32px;
  cursor: pointer;
  padding: 12px;
  line-height: 1;
  transition: color 0.15s ease-out;
  margin-top: -32px;
}
.lightbox-nav:hover { color: var(--lightbox-control-hover); }
.lightbox-prev { left: -56px; }
.lightbox-next { right: -56px; }

.hero-name,
.hero-title,
.work-thumb-placeholder,
.work-label .client,
.work-label .campaign,
.about-col p,
.award-item,
.award-detail,
#contact,
.contact-heading,
footer,
.lightbox-media,
.lightbox-client,
.lightbox-campaign,
.lightbox-desc,
.lightbox-counter,
.nav-toggle {
  transition-property: background-color, color, border-color, opacity;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

/* ---- Scroll entrance animations ---- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  nav {
    transition: none;
  }
  body,
  .nav-toggle,
  .nav-toggle span,
  .work-thumb,
  .work-thumb::before,
  .work-thumb::after,
  .work-thumb img,
  .work-label,
  .lightbox-overlay,
  .lightbox-panel,
  nav a,
  nav a::after,
  .theme-toggle,
  .hero-links a::after,
  .contact-links a::after {
    transition: none;
  }
}

/* ---- Responsive ---- */
@media (max-width: 1100px) and (min-width: 769px) {
  #hero { grid-template-columns: 40fr 60fr; }
}

@media (max-width: 900px) {
  .work-grid { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .awards-grid { grid-template-columns: 1fr; }

  .lightbox-prev { left: -40px; }
  .lightbox-next { right: -40px; }
}

@media (max-width: 768px) {
  nav { padding: 20px max(24px, env(safe-area-inset-right)); padding-left: max(24px, env(safe-area-inset-left)); }
  nav .nav-links { display: none; flex-direction: column; gap: 20px; }
  nav .nav-links.open {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--nav-menu-bg);
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 99;
  }
  nav .nav-links.open a {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: none;
    color: var(--text);
    padding: 4px 0;
  }
  nav .nav-links.open a::after { display: none; }
  .nav-actions {
    gap: 8px;
    position: relative;
    z-index: 101;
  }
  .theme-toggle {
    min-width: 64px;
    padding: 0 10px;
  }
  .nav-toggle { display: flex; position: relative; z-index: 101; }

  #hero {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100svh;
    padding: 0;
  }
  .hero-photo { order: -1; }
  .hero-content {
    padding: 36px 24px 56px;
    justify-content: flex-start;
  }
  .hero-name { font-size: clamp(48px, 13vw, 72px); margin-bottom: 16px; }

  section { padding: 64px max(24px, env(safe-area-inset-right)); padding-left: max(24px, env(safe-area-inset-left)); }
  .section-heading { font-size: 36px; margin-bottom: 32px; }

  .work-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  footer { padding: 32px max(24px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)); padding-left: max(24px, env(safe-area-inset-left)); }

  .lightbox-panel { width: 90vw; max-width: 90vw; }
  .lightbox-prev, .lightbox-next { display: none; }
  .lightbox-close { top: -36px; }

  /* Drag-to-dismiss handle */
  .lightbox-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 3px;
    background: var(--lightbox-drag-handle);
    margin: 0 auto 14px;
  }
}

/* ---- Custom cursor (desktop / hover-capable only) ---- */
@media (hover: hover) and (pointer: fine) {
  * { cursor: none !important; }

  .cursor {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10000;
  }
  .cursor-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--text);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.18s ease-out, height 0.18s ease-out, background-color 0.18s ease-out;
    will-change: transform;
  }
  .cursor-ring {
    position: absolute;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--text);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.25;
    transition: width 0.22s ease-out, height 0.22s ease-out, border-color 0.22s ease-out, opacity 0.22s ease-out;
    will-change: transform;
  }
  .cursor--hover .cursor-dot {
    width: 12px;
    height: 12px;
    background-color: var(--accent);
  }
  .cursor--hover .cursor-ring {
    width: 52px;
    height: 52px;
    border-color: var(--accent);
    opacity: 0.35;
  }
  .cursor--hidden { opacity: 0; }
}
