/* ========================
   Main Styles
   ======================== */
@import "base.css";

:root {
  --safari-chrome-color: #050505;
}

html,
body {
  height: 100%;
  background: var(--safari-chrome-color);
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  background: var(--safari-chrome-color);
}

/* ========================
   Layout / Panels
   ======================== */
.panel {
  width: 100%;
  position: relative;
  display: grid;
  align-items: center;
  overflow: hidden;
}

.container {
  width: min(var(--max-w), 90vw);
  margin: 0 auto;
}

.narrow {
  width: min(1000px, 90vw);
}

/* ========================
   Text Content Animation
   ======================== */
/* Apply fade-in to main content elements */
.brand,
.hero-nav,
.hero-cta__arrow,
.hero__aside {
  animation: fadeIn 1.5s ease-out forwards;
  opacity: 0;
}

/* Staggered delays for hero section */
.brand {
  animation-delay: 0.1s;
}

.hero-nav {
  animation-delay: 0.2s;
}

.hero-cta__arrow {
  animation-delay: 0.25s;
}

.hero__aside {
  animation-delay: 0.3s;
}

/* Scroll-triggered animation for elements below hero */
.fade-on-scroll {
  opacity: 0;
  transition: opacity 0.8s ease-out;
}

.fade-on-scroll.visible {
  opacity: 1;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .brand,
  .hero-nav,
  .hero-cta__arrow,
  .hero__aside {
    animation: none;
    opacity: 1;
  }

  .fade-on-scroll {
    opacity: 1;
    transition: none;
  }
}

/* ========================
   Section: Hero
   ======================== */
.hero {
  color: var(--ink);
  background-color: #000;
  background-image: url("../content/hero-texture.jpg");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  isolation: isolate;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6));
  z-index: 0;
}

.hero__inner {
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 4vw, 48px);
  padding-block: clamp(48px, 9vh, 120px);
  align-items: center; /* vertically center both grid columns */
}

.logo {
  margin: 0 0 0.25rem 0;
  line-height: 0.9;
  letter-spacing: 0.02em;
  font-family:
    "Black Mango", "Noto Serif Display", "Noto Serif Display ExtraCondensed",
    "Playfair Display", Georgia, serif;
  font-weight: 500;
  font-size: clamp(70px, 8vw, 96px);
  text-transform: uppercase;
}

.logo span {
  display: block;
}

.tag {
  margin: 0.25rem 0 0 0;
  font-size: clamp(10px, 1.5vw, 14px);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* for brands who want clarity */
.hero__aside {
  align-self: center; /* center vertically to match other panels */
  /* text-align: right; */
  font-weight: normal;
  font-family: "Playfair Display", Georgia, serif;
  text-transform: uppercase;
}

.aside-big {
  margin: 0 0 0.35rem 0;
  /* increased responsive size so the aside reads larger on most viewports */
  font-size: clamp(18px, 3vw, 32px);
  font-weight: normal;
}

.aside-small {
  margin: 0;
  font-size: clamp(14px, 1.8vw, 18px);
  font-family:
    "Montserrat",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;
  opacity: 0.9;
}

/* Hero navigation container */
.hero-nav {
  position: absolute;
  left: 50%;
  /* position above the arrow */
  bottom: clamp(120px, 13vh, 200px);
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: clamp(24px, 4vw, 48px);
  align-items: center;
  justify-content: center;
}

/* Hero centered CTA placed between the brand and the bottom */
.hero-cta {
  position: static;
  text-decoration: none;
  color: #fff;
  display: inline-block;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 600;
  font-size: clamp(14px, 2.5vw, 20px);
  opacity: 0.95;
}

/* Lift the nav above iOS Safari's bottom bar/notch safe area */
.hero-nav {
  bottom: calc(clamp(96px, 10vh, 160px) + env(safe-area-inset-bottom));
}

@supports (
  bottom: calc(clamp(96px, 10vh, 160px) + constant(safe-area-inset-bottom))
) {
  .hero-nav {
    bottom: calc(clamp(96px, 10vh, 160px) + constant(safe-area-inset-bottom));
  }
}

/* Make the label slightly transparent */
.hero-cta > span {
  opacity: 0.72;
}

.hero-cta:hover > span {
  opacity: 1;
}

.hero-cta__arrow {
  position: absolute;
  left: 50%;
  /* Position halfway between the nav and the bottom */
  bottom: clamp(48px, 5vh, 80px);
  transform: translateX(-50%);
  z-index: 2;
  opacity: 1;
  color: #fff;
  display: block;
  font-size: clamp(24px, 4vw, 28px);
  line-height: 1;
  transition: transform 320ms ease;
  /* subtle up-down animation to draw attention */
  animation: heroArrowFloat 2.4s ease-in-out infinite;
}

@keyframes heroArrowFloat {
  0% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(6px);
  }
  100% {
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 640px) {
  .hero-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 10px;
    width: min(84vw, 360px);
    bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .hero-cta {
    flex: 1 1 calc(50% - 10px);
    min-width: 132px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 999px;
    text-align: center;
    font-size: clamp(13px, 3.2vw, 16px);
    line-height: 1.1;
    background: rgba(26, 26, 26, 0.38);
    border: 1px solid rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  }

  .hero-cta > span {
    opacity: 0.9;
  }

  .hero-cta__arrow {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }

  @supports (bottom: calc(92px + constant(safe-area-inset-bottom))) {
    .hero-nav {
      bottom: calc(92px + constant(safe-area-inset-bottom));
    }

    .hero-cta__arrow {
      bottom: calc(24px + constant(safe-area-inset-bottom));
    }
  }

  .hero-cta:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
  }
}

@media (max-width: 480px) {
  .hero-nav {
    width: min(84vw, 300px);
    gap: 8px;
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .hero-cta {
    min-height: 38px;
    min-width: 124px;
    padding: 7px 12px;
    font-size: clamp(13px, 3.8vw, 15px);
  }

  @supports (bottom: calc(88px + constant(safe-area-inset-bottom))) {
    .hero-nav {
      bottom: calc(88px + constant(safe-area-inset-bottom));
    }
  }
}

/* ========================
   Section: Manifesto
   ======================== */
.manifesto {
  background: #7a0f0f
    linear-gradient(180deg, var(--wine) 0%, var(--wine-deep) 100%);
  color: #fff;
}

.manifesto__grid {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: clamp(24px, 5vw, 64px);
  padding-block: clamp(48px, 9vh, 120px);
  align-items: center; /* vertically center manifesto columns to match other sections */
}

.manifesto__quote {
  margin: 0;
  font-style: italic;
  font-family:
    "Playfair Display", Georgia, serif; /* substitute for Black Mango */
  font-weight: 600;
  font-size: clamp(41.4px, 9.2vw, 92px);
  line-height: 1.06;
}

.manifesto__quote span {
  display: block;
}
.manifesto__copy p {
  margin: 0 0 1rem 0;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.6;
}

.manifesto__copy {
  align-self: center; /* center the copy block vertically within the grid */
  width: 100%;
  max-width: 55ch; /* narrower measure so text wraps sooner */
}

.rule {
  width: 70%;
  height: 1px;
  border: 0;
  background: rgba(255, 255, 255, 0.35);
  margin-top: 2rem;
}

/* ========================
   Section: Services
   ======================== */
.services {
  background: #fff;
  color: var(--text);
}

.section-head {
  text-align: center;
  margin-bottom: clamp(48px, 8vh, 80px);
  color: #0d1747;
}

.section-head .eyebrow {
  margin: 0;
  font-family:
    "Black Mango", "Noto Serif Display", "Playfair Display", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.08em;
  font-size: clamp(48px, 9vw, 96px);
  line-height: 0.9;
}

.section-head .title {
  margin: 0;
  font-family:
    "Black Mango", "Noto Serif Display", "Playfair Display", Georgia, serif;
  letter-spacing: 0.06em;
  font-weight: 500;
  font-size: clamp(48px, 9vw, 96px);
  line-height: 0.9;
  text-transform: uppercase;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2.5vw, 32px);
}

.card {
  /* background: #f7f7f7; */
  border-radius: var(--radius);
  padding: clamp(16px, 2.5vw, 28px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.card h3 {
  margin-top: 0;
  font-family:
    "Black Mango", "Noto Serif Display", "Playfair Display", Georgia, serif;
  text-transform: uppercase;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.card p {
  margin-bottom: 0;
  color: #333;
  line-height: 1.65;
}

/* ========================
   Section: Portfolio
   ======================== */
.portfolio {
  background: #fff;
  color: var(--text);
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(32px, 5vw, 64px);
}

.portfolio-card {
  aspect-ratio: 2/3;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

@media (hover: hover) {
  .portfolio-card:hover {
    transform: scale(1.05) translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  }
}

.portfolio-card__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}

.portfolio-card__bg--alford {
  background-image: url("../content/portfolio/alford/alford-bg.webp");
}

.portfolio-card__bg--townpump {
  background-image: url("../content/portfolio/townpump/otp-bg.webp");
}

.portfolio-card__bg--1905 {
  background-image: url("../content/portfolio/1905/1905-bg.webp");
}

.portfolio-card__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(0, 0, 0, 0.9) 100%
  );
}

.portfolio-card__logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 60%;
  max-height: 40%;
  object-fit: contain;
  z-index: 2;
  transition: opacity 0.3s ease;
}

.portfolio-card__cta {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: rgb(228, 219, 219);
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

@media (hover: hover) {
  .portfolio-card:hover .portfolio-card__logo {
    opacity: 0;
  }

  .portfolio-card:hover .portfolio-card__cta {
    opacity: 1;
  }
}

.portfolio-card__name {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: clamp(16px, 2vw, 24px);
  font-family: var(--font-display);
  font-size: clamp(14px, 1.8vw, 20px);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  text-align: center;
}

/* ========================
   Portfolio Modal
   ======================== */
.portfolio-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.portfolio-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.portfolio-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 100vh));
  z-index: 10000;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
  width: min(900px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  transition: transform 0.4s ease;
}

.portfolio-modal.visible {
  transform: translate(-50%, -50%);
}

.portfolio-modal__close {
  position: sticky;
  top: 16px;
  float: right;
  margin: 16px 16px 0 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  color: #333;
  transition: all 0.3s ease;
  z-index: 10;
}

.portfolio-modal__close:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
}

.portfolio-modal__content {
  display: none;
  padding: clamp(24px, 5vw, 48px);
  padding-top: 0;
}

.portfolio-modal__content.visible {
  display: block;
}

.portfolio-modal__header {
  text-align: center;
  margin-bottom: clamp(24px, 4vw, 40px);
}

.portfolio-modal__brand-name {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}

.portfolio-modal__tagline {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(16px, 2vw, 20px);
  color: var(--muted);
}

.portfolio-modal__section {
  margin-bottom: clamp(32px, 5vw, 48px);
}

.portfolio-modal__section-title {
  margin: 0 0 16px 0;
  font-family: var(--font-display);
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
}

.portfolio-modal__description {
  font-size: clamp(15px, 1.8vw, 17px);
  line-height: 1.7;
  color: #444;
}

.portfolio-modal__video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
}

.portfolio-modal__video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.portfolio-modal__gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 1.5vw, 16px);
}

.portfolio-modal__gallery img {
  width: 100%;
  border-radius: calc(var(--radius) / 2);
  aspect-ratio: 4/3;
  object-fit: cover;
}

.portfolio-modal__instagram {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(16px, 2vw, 24px);
  justify-items: center;
}

/* ========================
  Section: Story
  ======================== */
.story {
  background: #95c1ce;
  color: #fff;
}

.story__grid {
  display: grid;
  /* text column + image column; image column is constrained and will
     shrink proportionally as the viewport narrows */
  grid-template-columns: 1fr minmax(120px, min(40%, 520px));
  gap: clamp(24px, 4vw, 48px);
  align-items: center;
  padding-block: clamp(48px, 9vh, 120px);
}

.story .eyebrow,
.story .title {
  margin: 0;
  font-family:
    "Black Mango", "Noto Serif Display", "Playfair Display", Georgia, sans-serif;
  font-weight: 800;
  font-size: clamp(57.6px, 10.8vw, 115.2px);
  line-height: 0.9;
}

.story .lede {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  margin-top: 1rem;
  font-size: clamp(
    14.4px,
    2.7vw,
    28.8px
  ); /* 25% of .story .eyebrow's clamp(57.6px, 10.8vw, 115.2px) */
}

.lede-sub {
  font-size: clamp(
    14.4px,
    2.7vw,
    28.8px
  ); /* 25% of .story .eyebrow's clamp(57.6px, 10.8vw, 115.2px) */
}

.story__image {
  margin: 0;
  display: grid;
  place-items: center;
  justify-self: end; /* keep the image anchored to the right column */
  align-self: center;
}

.story__image img {
  width: 100%;
  max-width: 100%;
  height: auto;
  /* Cap height so the panel doesn't exceed the viewport on shorter screens,
     preventing extra scroll snaps on reduced-height viewports */
  max-height: calc(100vh - 160px);
  max-height: calc(100svh - 160px);
  max-height: calc(100dvh - 160px);
  object-fit: cover;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* Panel back button - top right corner */
.panel__back-btn {
  position: absolute;
  right: clamp(20px, 3vw, 40px);
  top: calc(clamp(20px, 3vw, 40px) + env(safe-area-inset-top));
  z-index: 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  text-decoration: none;
  font-size: 24px;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

@supports (top: calc(20px + constant(safe-area-inset-top))) {
  .panel__back-btn {
    top: calc(clamp(20px, 3vw, 40px) + constant(safe-area-inset-top));
  }
}

.panel__back-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-4px);
}

.panel__back-btn span {
  display: block;
  line-height: 1;
}

/* Dark variant for light background sections */
.services .panel__back-btn,
.portfolio .panel__back-btn {
  background: rgba(0, 0, 0, 0.15);
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.2);
}

.services .panel__back-btn:hover,
.portfolio .panel__back-btn:hover {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(0, 0, 0, 0.35);
}

/* ========================
   Section: Contact
   ======================== */

.contact {
  color: #fff;
  overflow: hidden;
}

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

/* Top-left brand label for Contact panel */
.contact__brand {
  position: absolute;
  left: 24px;
  top: 18px;
  z-index: 2;
  font-family: "Black Mango", "Noto Serif Display", "Playfair Display", serif;
  font-weight: 700;
  color: #fff;
  font-size: clamp(18px, 2.6vw, 34px);
  letter-spacing: 0.02em;
  pointer-events: none;
}

.contact__bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.55);
}

.contact__grid {
  position: relative;
  z-index: 1;
  display: grid;
  /* keep the left column flexible while constraining the form column so inputs don't stretch too wide */
  grid-template-columns: 1fr min(520px, 40%);
  gap: clamp(24px, 4vw, 48px);
  min-height: 100vh;
  align-content: center;
  align-items: center;
}

.contact__head h2 {
  margin: 0 0 0.5rem 0;
  font-family:
    "Black Mango", "Noto Serif Display", "Playfair Display", Georgia, serif;
  font-weight: 500;
  font-size: clamp(43.7px, 6.9vw, 73.6px); /* increased by 15% */
  text-transform: uppercase;
}

.contact__head p {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  opacity: 0.95;
  font-size: 1.5em; /* increased by 25% relative to inherited size */
}

.contact__form {
  display: grid;
  gap: 12px;
  align-content: start;
  width: 100%;
  max-width: 520px; /* keep form fields from expanding to the full column width */
  align-self: center;
}

.contact__form input,
.contact__form textarea {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
}

.contact__form input::placeholder,
.contact__form textarea::placeholder {
  color: #444;
}

.contact__form button {
  margin-top: 8px;
  justify-self: start;
  border: 0;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  background: #ffffff;
  color: #111;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* Contact back button - positioned at the very bottom */
.contact__back-btn {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  text-decoration: none;
  font-size: 24px;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.contact__back-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateX(-50%) translateY(-4px);
}

.contact__back-btn span {
  display: block;
  line-height: 1;
}

/* ========================
   Utilities
   ======================== */
.sr-only {
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0 !important;
  border: 0 !important;
  height: 1px !important;
  width: 1px !important;
  overflow: hidden;
}

/* ========================
   Responsive
   ======================== */
@media (max-width: 1024px) {
  .hero__inner {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .hero__aside {
    text-align: left;
  }
  .manifesto__grid {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: 1fr 1fr;
  }
  .panel.portfolio {
    display: flex;
    flex-direction: column;
    padding: clamp(24px, 5dvh, 48px) 0;
  }
  .portfolio .container.narrow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .portfolio .section-head {
    flex-shrink: 0;
    margin-bottom: clamp(16px, 3dvh, 32px);
  }
  .portfolio-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2dvh, 20px);
    min-height: 0;
  }
  .portfolio-card {
    flex: 1;
    aspect-ratio: unset;
    min-height: 0;
  }
  .portfolio-card__logo {
    max-width: 50%;
    max-height: 70%;
  }
  .portfolio-card__name {
    display: none;
  }
  .story__grid {
    grid-template-columns: 1fr;
  }
  .story__image img {
    max-height: 40svh;
    max-height: 40dvh;
  }
  .contact__grid {
    grid-template-columns: 1fr;
  }

  /* move contact brand to the right on narrower viewports to avoid
     colliding with the contact header */
  .contact__brand {
    left: auto;
    right: 18px;
    text-align: right;
    font-size: clamp(14px, 3.5vw, 24px);
  }
}

@media (max-width: 768px) {
  .portfolio-modal__close {
    float: none;
    position: sticky;
    top: 12px;
    margin: 12px 12px 10px auto;
    display: grid;
  }
}

@media (max-width: 640px) {
  .section-head {
    margin-bottom: clamp(24px, 5vh, 40px);
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .services .section-head {
    margin-bottom: clamp(18px, 3.4vh, 30px);
  }
  .services .cards {
    gap: clamp(10px, 1.8dvh, 16px);
  }
  .services .card {
    padding: clamp(14px, 2.2vw, 20px);
  }
  .services .card h3 {
    margin-bottom: clamp(10px, 1.8dvh, 16px);
  }
  .services .card p {
    font-size: clamp(15px, 3.8vw, 18px);
    line-height: 1.58;
  }
  .portfolio-modal {
    width: 100vw;
    max-height: 75vh;
    max-height: 75dvh;
    border-radius: var(--radius);
  }
  .portfolio-modal__gallery {
    grid-template-columns: 1fr;
  }

  .panel__back-btn {
    right: 16px;
    top: calc(16px + env(safe-area-inset-top));
  }

  .contact__grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    align-items: stretch;
    gap: clamp(12px, 2.8dvh, 24px);
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    padding-top: calc(92px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .contact__brand {
    left: 18px;
    right: auto;
    text-align: left;
    max-width: calc(100% - 108px);
  }

  .contact__head h2 {
    font-size: clamp(36px, 10.4vw, 52px);
    margin-bottom: 0.35rem;
  }

  .contact__head p {
    font-size: clamp(20px, 5.8vw, 28px);
    line-height: 1.03;
  }

  .contact__form {
    min-height: 0;
    align-self: stretch;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    gap: 10px;
  }

  .contact__form input,
  .contact__form textarea {
    padding: 12px 14px;
  }

  .contact__form button {
    margin-top: 4px;
  }

  .contact__back-btn {
    right: 16px;
    top: calc(16px + env(safe-area-inset-top));
    left: auto;
    bottom: auto;
    transform: none;
  }

  .contact__back-btn:hover {
    transform: translateY(-4px);
  }
}

@media (max-width: 640px) and (max-height: 760px) {
  .contact__grid {
    gap: clamp(8px, 2dvh, 14px);
    padding-top: calc(78px + env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .contact__head h2 {
    font-size: clamp(34px, 9.6vw, 48px);
    margin-bottom: 0.25rem;
  }

  .contact__head p {
    font-size: clamp(18px, 5.2vw, 24px);
    line-height: 1.02;
  }

  .contact__form {
    gap: 8px;
  }

  .contact__form input,
  .contact__form textarea {
    padding: 11px 13px;
  }

  .contact__form textarea {
    min-height: 108px;
  }

  .contact__form button {
    padding: 11px 16px;
  }
}

@supports (padding-top: calc(1px + constant(safe-area-inset-top))) {
  @media (max-width: 640px) {
    .contact__grid {
      padding-top: calc(92px + constant(safe-area-inset-top));
    }

    .contact__back-btn {
      top: calc(16px + constant(safe-area-inset-top));
    }
  }
}

@supports (top: calc(16px + constant(safe-area-inset-top))) {
  @media (max-width: 640px) {
    .panel__back-btn {
      top: calc(16px + constant(safe-area-inset-top));
    }
  }
}

@supports (padding-bottom: calc(1px + constant(safe-area-inset-bottom))) {
  @media (max-width: 640px) {
    .contact__grid {
      padding-bottom: calc(20px + constant(safe-area-inset-bottom));
    }
  }
}

@supports (padding-top: calc(1px + constant(safe-area-inset-top))) {
  @media (max-width: 640px) and (max-height: 760px) {
    .contact__grid {
      padding-top: calc(78px + constant(safe-area-inset-top));
    }
  }
}

@supports (padding-bottom: calc(1px + constant(safe-area-inset-bottom))) {
  @media (max-width: 640px) and (max-height: 760px) {
    .contact__grid {
      padding-bottom: calc(14px + constant(safe-area-inset-bottom));
    }
  }
}

/* Height-aware adjustments: when the viewport is short, reduce paddings
   and large display font sizes so content fits within the fixed-height
   panels and doesn't get clipped at the bottom. */
@media (max-height: 800px) {
  .manifesto__grid,
  .story__grid,
  .hero__inner {
    padding-block: clamp(24px, 6vh, 80px);
  }

  .story__grid {
    padding-block: clamp(24px, 6dvh, 80px);
  }

  .manifesto__quote {
    font-size: clamp(40px, 6vw, 56px);
    line-height: 1.04;
  }

  .story .eyebrow,
  .story .title {
    font-size: clamp(34px, 7vw, 72px);
    line-height: 1.02;
  }

  .story__image img {
    max-height: 40svh;
    max-height: 40dvh;
  }
}

@media (max-height: 640px) {
  .manifesto__grid,
  .story__grid,
  .hero__inner {
    padding-block: clamp(16px, 4vh, 48px);
  }

  .story__grid {
    padding-block: clamp(16px, 4dvh, 48px);
  }

  .manifesto__quote {
    font-size: clamp(22px, 6vw, 44px);
  }

  .story .eyebrow,
  .story .title {
    font-size: clamp(28px, 8vw, 56px);
  }

  .story__image img {
    max-height: 35svh;
    max-height: 35dvh;
  }
}

@media (max-width: 520px) and (max-height: 760px) {
  .services {
    align-items: start;
  }

  .services .container.narrow {
    padding-top: calc(clamp(16px, 3svh, 28px) + env(safe-area-inset-top));
    padding-bottom: clamp(12px, 2.8dvh, 24px);
  }

  .services .section-head {
    margin-bottom: clamp(14px, 2.8dvh, 22px);
  }

  .services .section-head .eyebrow,
  .services .section-head .title {
    font-size: clamp(40px, 14vw, 72px);
    line-height: 0.92;
  }

  .services .cards {
    gap: clamp(8px, 1.4dvh, 12px);
  }

  .services .card {
    padding: clamp(12px, 3.2vw, 16px);
  }

  .services .card h3 {
    margin: 0 0 clamp(8px, 1.2dvh, 12px) 0;
    font-size: clamp(15px, 4.3vw, 19px);
  }

  .services .card p {
    font-size: clamp(15px, 3.9vw, 17px);
    line-height: 1.52;
  }
}

@supports (padding-top: calc(1px + constant(safe-area-inset-top))) {
  @media (max-width: 520px) and (max-height: 760px) {
    .services .container.narrow {
      padding-top: calc(
        clamp(16px, 3svh, 28px) + constant(safe-area-inset-top)
      );
    }
  }
}

@media (max-width: 520px) and (max-height: 700px) {
  .services .container.narrow {
    padding-top: calc(clamp(12px, 2.6svh, 22px) + env(safe-area-inset-top));
    padding-bottom: calc(
      clamp(16px, 3.4dvh, 26px) + env(safe-area-inset-bottom)
    );
  }

  .services .section-head {
    margin-bottom: clamp(10px, 2.2dvh, 18px);
  }

  .services .section-head .eyebrow,
  .services .section-head .title {
    font-size: clamp(34px, 10.6vw, 44px);
    line-height: 0.9;
  }

  .services .cards {
    gap: clamp(6px, 1.1dvh, 10px);
  }

  .services .card {
    padding: clamp(10px, 2.8vw, 14px);
  }

  .services .card h3 {
    margin-bottom: clamp(6px, 1dvh, 10px);
    font-size: clamp(15px, 4vw, 18px);
  }

  .services .card p {
    font-size: clamp(15px, 3.7vw, 16px);
    line-height: 1.45;
  }
}

@supports (padding-bottom: calc(1px + constant(safe-area-inset-bottom))) {
  @media (max-width: 520px) and (max-height: 700px) {
    .services .container.narrow {
      padding-bottom: calc(
        clamp(16px, 3.4dvh, 26px) + constant(safe-area-inset-bottom)
      );
    }
  }
}

/* Mobile-first story overrides:
   1) keep display type expressive on typical phone heights
   2) adapt aggressively on short heights so Safari chrome does not clip the heading */
@media (max-width: 520px) {
  .story__grid {
    padding-top: calc(clamp(24px, 6svh, 80px) + env(safe-area-inset-top));
    padding-bottom: clamp(20px, 6dvh, 72px);
    gap: clamp(14px, 4vw, 32px);
  }

  .story .eyebrow,
  .story .title {
    font-size: clamp(46px, 10.4vw, 96px);
    line-height: 1;
  }

  .story .lede,
  .lede-sub {
    font-size: clamp(17px, 4.2vw, 22px);
    line-height: 1.42;
  }

  .story__image img {
    max-height: 38svh;
    max-height: 38dvh;
    object-fit: cover;
  }
}

@supports (padding-top: calc(1px + constant(safe-area-inset-top))) {
  @media (max-width: 520px) {
    .story__grid {
      padding-top: calc(
        clamp(24px, 6svh, 80px) + constant(safe-area-inset-top)
      );
    }
  }
}

@media (max-width: 520px) and (min-height: 701px) {
  .story {
    align-items: start;
  }

  .story .eyebrow,
  .story .title {
    font-size: clamp(52px, 12vw, 102px);
    line-height: 1;
  }

  .story .lede,
  .lede-sub {
    font-size: clamp(17px, 4.4vw, 22px);
    line-height: 1.4;
  }

  .story__image img {
    max-height: 42svh;
    max-height: 42dvh;
  }
}

@media (max-width: 520px) and (max-height: 700px) {
  .story {
    align-items: center;
  }

  .story__grid {
    padding-top: calc(clamp(14px, 3.5svh, 32px) + env(safe-area-inset-top));
    padding-bottom: clamp(14px, 3.5dvh, 32px);
    gap: clamp(12px, 3.5vw, 24px);
  }

  .story .eyebrow,
  .story .title {
    font-size: clamp(38px, 12vw, 66px);
    line-height: 0.98;
  }

  .story .lede,
  .lede-sub {
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.35;
  }

  .story__image img {
    max-height: 30svh;
    max-height: 30dvh;
  }
}

@supports (padding-top: calc(1px + constant(safe-area-inset-top))) {
  @media (max-width: 520px) and (max-height: 700px) {
    .story__grid {
      padding-top: calc(
        clamp(14px, 3.5svh, 32px) + constant(safe-area-inset-top)
      );
    }
  }
}
