/* =========================================================
   Matthew Brown — Portfolio
   Base stylesheet
   ========================================================= */

:root {
  --color-text: #333333;
  --color-text-muted: #6b6b6b;
  --color-bg: #fafafa;
  --color-bg-alt: #f1f1f1;
  --color-border: #e2e2e2;
  --color-accent: #2f6fed;
  --color-accent-hover: #1d4fbf;

  --font-heading: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --text-xs: 0.85rem;
  --text-sm: 0.95rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.3rem;
  --text-2xl: 1.8rem;
  --text-3xl: 2.6rem;

  --max-width: 1120px;
  --gutter: 24px;

  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 32px;
  --space-lg: 64px;
  --space-xl: 96px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-sm);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); font-weight: 600; }
h2 { font-size: var(--text-2xl); font-weight: 600; }
h3 { font-size: var(--text-xl); letter-spacing: 0; }
h4 { font-size: var(--text-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); }

p {
  margin: 0 0 var(--space-sm);
}

ul {
  margin: 0 0 var(--space-sm);
  padding-left: 1.2em;
}

blockquote {
  margin: var(--space-md) 0;
  padding-left: var(--space-sm);
  border-left: 3px solid var(--color-accent);
  font-family: var(--font-body);
  font-style: italic;
  color: var(--color-text-muted);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header / Nav ---------- */

.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
}

.site-logo {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.site-logo a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  transition: color 0.15s ease;
}

.site-logo a:hover {
  text-decoration: none;
  color: var(--color-accent);
}

.site-logo-mark {
  width: 28px;
  height: 28px;
  display: block;
}

.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-md);
}

.main-nav a {
  color: var(--color-text);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  color: var(--color-accent);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 10px;
  margin: -10px;
  cursor: pointer;
  color: var(--color-text);
  transition: color 0.15s ease;
}

.nav-toggle:hover {
  color: var(--color-accent);
}

/* ---------- Hero ---------- */

.hero {
  padding: var(--space-xl) 0 var(--space-lg);
  text-align: center;
}

.hero p.tagline {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Work grid ---------- */

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
  padding: var(--space-md) 0 var(--space-xl);
}

.work-card {
  display: block;
  color: inherit;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.work-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  text-decoration: none;
}

.work-card .thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.work-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.work-card:hover .thumb img {
  transform: scale(1.05);
}

.work-card .card-body {
  padding: var(--space-sm) var(--space-sm);
}

.work-card h3 {
  margin-bottom: 4px;
}

.work-card .meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

section.section-heading {
  padding-top: var(--space-lg);
}

section.section-heading h2 {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-sm);
}

/* ---------- About page ---------- */

.about-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
  max-width: 720px;
  margin: 0 auto;
}

.about-layout h4 {
  margin-top: var(--space-xl);
}

.brand-list {
  columns: 2;
  column-gap: var(--space-md);
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0 0;
}

.brand-list li {
  break-inside: avoid;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.quote-block {
  margin: var(--space-md) 0;
  padding-left: var(--space-sm);
  border-left: 3px solid var(--color-accent);
}

.quote-block p:first-child {
  font-weight: 600;
  font-style: normal;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.quote-block p:last-child {
  color: var(--color-text-muted);
  margin-bottom: 0;
}

.values-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin: var(--space-md) 0;
}

.values-grid h4 {
  margin: 0 0 4px;
}

.values-grid p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.timeline {
  margin: var(--space-md) 0;
}

.timeline-item {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-item h3 {
  margin-bottom: 2px;
}

.timeline-item .meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xs);
}

.timeline-item p:last-child {
  margin: 0;
  color: var(--color-text-muted);
}

/* ---------- Case study page ---------- */

.case-study-header {
  padding: var(--space-lg) 0 var(--space-md);
  max-width: 720px;
}

.case-study-header .meta {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xs);
}

.case-study-body {
  max-width: 720px;
  padding-bottom: var(--space-md);
}

.case-study-body h4 {
  margin-top: var(--space-md);
}

.case-study-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-sm);
  padding: var(--space-md) 0 var(--space-xl);
}

.case-study-gallery img {
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.case-study-gallery figure {
  margin: 0;
}

.case-study-gallery figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding-top: 4px;
}

.back-link {
  display: inline-block;
  padding: 6px 0;
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
  transition: transform 0.15s ease, color 0.15s ease;
}

.back-link:hover {
  transform: translateX(-3px);
}

/* ---------- Case study carousel ---------- */

.carousel {
  position: relative;
  max-width: 720px;
  margin: var(--space-md) 0 var(--space-lg);
}

.carousel:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.carousel-viewport {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}

.carousel-slide.is-active {
  opacity: 1;
  pointer-events: auto;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  text-align: center;
  padding: var(--space-sm);
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s ease, color 0.15s ease;
}

.carousel-arrow:hover {
  background: #fff;
  color: var(--color-accent);
  text-decoration: none;
}

.carousel-arrow--prev { left: var(--space-xs); }
.carousel-arrow--next { right: var(--space-xs); }

.carousel-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-sm);
}

.carousel-dot {
  width: 5px;
  height: 5px;
  padding: 6px;
  box-sizing: content-box;
  background-clip: content-box;
  border: none;
  border-radius: 50%;
  background: var(--color-border);
  opacity: 0.8;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, width 0.15s ease;
}

.carousel-dot:hover {
  background: var(--color-text-muted);
  opacity: 1;
}

.carousel-dot.is-active {
  width: 14px;
  border-radius: 3px;
  background: var(--color-text-muted);
  opacity: 1;
}

/* ---------- Visual design gallery (masonry-ish) ---------- */

.gallery-grid {
  columns: 3;
  column-gap: var(--space-sm);
  padding: var(--space-md) 0 var(--space-xl);
}

.gallery-grid figure {
  margin: 0 0 var(--space-sm);
  break-inside: avoid;
  overflow: hidden;
  border-radius: 4px;
}

.gallery-grid img {
  border-radius: 4px;
  transition: transform 0.4s ease;
}

.gallery-grid figure:hover img {
  transform: scale(1.05);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-md) 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--color-text-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .about-layout { padding: var(--space-md) 0; }
  .brand-list { columns: 1; }
  .gallery-grid { columns: 2; }
  h1 { font-size: 1.9rem; }

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
  }

  .main-nav.open {
    display: block;
  }

  .main-nav ul {
    flex-direction: column;
    padding: var(--space-sm) var(--gutter);
    gap: var(--space-xs);
  }

  .main-nav a {
    display: block;
    padding: 10px 0;
  }

  .nav-toggle {
    display: block;
  }
}

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

  .carousel-arrow {
    width: 44px;
    height: 44px;
  }
}

/* ---------- Scroll-reveal (progressive content fade-in) ---------- */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------- Visual design: project intro (hero image + text sidebar) ---------- */

.visual-project-intro {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: var(--space-md);
  align-items: start;
  padding: var(--space-lg) 0 var(--space-md);
}

.visual-project-hero-figure {
  margin: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.visual-project-hero-figure img {
  width: 100%;
  display: block;
}

.visual-project-info h1 {
  font-size: var(--text-xl);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-sm);
}

.visual-project-info .credit {
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
}

.visual-project-info .credit strong {
  display: block;
  color: var(--color-text);
  font-weight: 600;
}

.visual-project-info .year {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-md);
}

.visual-project-info .description {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .visual-project-intro {
    grid-template-columns: 1fr;
    padding: var(--space-md) 0 var(--space-sm);
  }
}

/* ---------- Visual design: alternating grid/hero sequence ---------- */

.visual-sequence {
  padding: var(--space-md) 0 var(--space-xl);
}

.visual-grid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.visual-grid-row figure {
  position: relative;
  margin: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 4px;
  background: var(--color-bg-alt);
}

.visual-grid-row img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  transition: transform 0.4s ease;
}

.visual-grid-row figure:hover img {
  transform: scale(1.05);
}

.visual-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 4px;
  margin: 0 0 var(--space-sm);
  background: var(--color-bg-alt);
}

.visual-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  transition: transform 0.4s ease;
}

.visual-hero:hover img {
  transform: scale(1.02);
}

@media (max-width: 480px) {
  .visual-grid-row {
    grid-template-columns: 1fr;
  }

  .visual-grid-row figure {
    aspect-ratio: 4 / 3;
  }

  .visual-hero {
    aspect-ratio: 4 / 3;
  }
}

/* ---------- Case study: mid-body breather image ---------- */

.case-study-break-image {
  margin: var(--space-lg) 0;
}

.case-study-break-image img {
  width: 100%;
  border-radius: 4px;
}

/* ---------- Password gate (Case Studies) ---------- */

.password-gate {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) 0;
}

.password-gate-card {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  text-align: center;
}

.password-gate-card h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-xs);
}

.password-gate-card p.tagline {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: 0;
  margin-bottom: var(--space-md);
}

.password-gate-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.password-gate-form input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.password-gate-form input[type="password"]:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.password-gate-form input[type="password"].is-error {
  border-color: #d64545;
}

.password-gate-form button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  background: linear-gradient(135deg, #4b83f0 0%, var(--color-accent) 50%, var(--color-accent-hover) 100%);
  background-size: 180% 180%;
  background-position: 0% 50%;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 4px 16px rgba(47, 111, 237, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-position 0.5s ease;
}

.password-gate-form button::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -75%;
  width: 50%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  z-index: -1;
}

.password-gate-form button::after {
  content: "\2192";
  display: inline-block;
  transition: transform 0.25s ease;
}

.password-gate-form button:hover {
  background-position: 100% 50%;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(47, 111, 237, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.password-gate-form button:hover::before {
  left: 125%;
}

.password-gate-form button:hover::after {
  transform: translateX(4px);
}

.password-gate-form button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 4px 14px rgba(47, 111, 237, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.password-gate-form button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.password-gate-error {
  color: #d64545;
  font-size: var(--text-xs);
  min-height: 1.2em;
  margin: 0;
}

.password-gate-content {
  display: none;
  padding: var(--space-lg) 0;
  text-align: center;
}

.password-gate-content.is-unlocked {
  display: block;
}

.password-gate.is-unlocked {
  display: none;
}

.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;
}
