/* 
 * PAGE SECTIONS - Specialized page components
 * 
 * Available sections:
 * Hero: .hero-section, .hero-overlay, .hero-content, .hero-text, .hero-title, .hero-subtitle
 * Navigation: .site-header, .navbar, .brand, .brand-logo, .navbar-links, .nav-link
 * Mobile: .navbar-toggle, .mobile-menu
 * Footer: .site-footer, .footer-inner, .section, .socials, .social-link
 * Portfolio: .portfolio-grid, .portfolio-card, .portfolio-card-image, .portfolio-card-content
 * Home: .work-grid, .work-tile, .work-tile-image, .work-tile-title, .work-tile-tag
 * Project page: .project-role, .project-group, .project-group-label, .project-group-image, .project-group-caption, .more-work, .work-grid--small
 * Comics: .comic-grid, .comic-card, .comic-card-image, .comic-carousel
 * Projects: .project-header
 * 
 * Use these for consistent page layouts and specialized content areas
 */

/* Hero Section */
.hero-section {
  position: relative;
  width: 100%;
  min-height: 400px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}

.series-wordmark {
  height: 200px;
  max-height: 200px;
  width: auto;
}

/* Utility to apply background-image via data attribute for hero */
.hero-section[data-bg] { 
  background-image: attr(data-bg url); 
}

@media (min-width: 768px) {
  .hero-section {
    min-height: 500px;
  }
}

@media (min-width: 1024px) {
  .hero-section {
    min-height: 600px;
  }
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--black-a50);
  background: linear-gradient(to bottom, var(--black-a30), var(--black-a60));
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 3rem 0;
}

.hero-text {
  text-align: center;
  color: var(--white);
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 3.5rem;
  }
}

@media (min-width: 1024px) {
  .hero-title {
    font-size: 4rem;
  }
}

.hero-subtitle {
  font-size: 1.25rem;
  font-weight: 400;
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
}

@media (min-width: 768px) {
  .hero-subtitle {
    font-size: 1.5rem;
  }
}

/* Navbar */
.site-header {
  position: sticky;
  z-index: 1002; /* Higher than mobile menu backdrop (999) */
  max-width: 1180px;
  margin: 0 auto;
  background: var(--background-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Floating panel state when scrolled */
.site-header.is-floating {
  background: var(--white-a70);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Mobile floating bottom navigation */
@media (max-width: 767px) {
  /* The bottom pill is CSS-only on phones, so it's in place on first paint
     (no slide-in from the top header on every page load) */
  .site-header {
    position: fixed;
    top: auto;
    bottom: 1rem;
    transition: none;
    background: var(--white-a70);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    width: calc(100% - 2rem);
    max-width: 400px;
    border-radius: var(--radius-surface);
    box-shadow: var(--shadow-float);
  }
  
  .site-header .navbar {
    padding: 0.75rem 1rem;
    height: auto;
    min-height: 3.5rem;
  }
  
  .site-header .navbar-left {
    width: calc(100% - 4rem);
    justify-content: center;
  }
  
  .site-header .brand {
    display: none;
  }
  
  .site-header .navbar-links {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    justify-content: space-between;
  }
  
  .site-header .nav-link {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
    text-align: center;
    min-width: 0;
    flex: 1;
    border-bottom: none;
  }
  
  .site-header .nav-link:hover {
    background: transparent;
    color: var(--text-primary);
    border-bottom: none;
  }
  
  .site-header .nav-link--active {
    background: var(--signal-yellow);
    color: var(--text-primary);
    border-bottom: none;
  }
  
  .site-header .navbar-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Desktop floating top navigation */
@media (min-width: 768px) {
  .site-header.is-floating {
    top: 1rem;
    margin: 0 2rem;
    border-radius: var(--radius-surface);
    box-shadow: var(--shadow-header);
  }
  
  .site-header.is-floating .navbar {
    padding: 0 1.5rem;
  }
}

@media (min-width: 1024px) {
  .site-header.is-floating {
    margin: 0 auto;
    max-width: 768px;
  }
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  padding: 0 var(--space-6);
}

/* Navbar layout sections */
.navbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-right {
  display: none;
  align-items: center;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .navbar-right {
    display: flex;
  }
}

.navbar-social {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-social {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-social .social-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  border: none;
}

.navbar-social .social-link:hover {
  color: var(--signal-yellow);
  border: none;
}

.nav-link--bordered {
  border: 1px solid var(--border-light);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-link--bordered:hover {
  border-color: var(--signal-yellow);
  background: var(--background-primary);
}

@media (min-width: 768px) {
  .navbar {
    height: 5rem;
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.brand:hover {
  color: var(--signal-yellow);
}

.brand-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  margin-right: 0.75rem;
  flex: 0 0 50px;
}

.navbar-links {
  display: none;
  align-items: center;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .navbar-links {
    display: flex;
  }
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  transition: color 0.2s ease;
}

/* Desktop nav underline: same token and drawing as text links, so nothing shifts on hover */
@media (min-width: 768px) {
  .site-header .nav-link:hover,
  .site-header .nav-link--active {
    box-shadow: 0 2px 0 var(--link-color);
  }
}

.navbar-actions {
  display: none;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .navbar-actions {
    display: flex;
  }
}

.navbar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  font-size: 20px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.navbar-toggle:hover {
  color: var(--text-primary);
}

@media (min-width: 1024px) {
  .navbar-toggle {
    display: none;
  }
}



/* Press states: no square system tap highlight; presses use the same rounded shape */
.site-header a,
.site-header button,
.mobile-menu a {
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 767px) {
  .site-header .nav-link:active:not(.nav-link--active) { background: var(--primary-100); }
  .site-header .navbar-toggle:active { background: var(--gray-200); }
}

/* Rotate the icon, not the button: on phones the button's own transform centers it */
.navbar-toggle svg { transition: transform 0.2s ease; }
.navbar-toggle.is-open svg { transform: rotate(90deg); }

.navbar-toggle .icon-close {
  display: none;
}

.navbar-toggle.is-open .icon-hamburger {
  display: none;
}

.navbar-toggle.is-open .icon-close {
  display: block;
}

/* Both icons share one centered 20px box, so the swap (and the rotation) stays aligned */
.navbar-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 1rem;
  width: 280px;
  background: var(--background-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-base);
  box-shadow: 0 4px 12px var(--black-a15);
  z-index: 1000;
}

.mobile-menu::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: var(--background-secondary);
  border-left: 1px solid var(--border-light);
  border-top: 1px solid var(--border-light);
  transform: rotate(45deg);
}

/* Mobile popup menu when header is floating */
@media (max-width: 767px) {
  .site-header.is-floating .mobile-menu {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: calc(100% - 2rem);
    max-width: 320px;
    border-radius: var(--radius-surface);
    background: var(--white-a98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-float);
    z-index: 1001;
  }
  
  .site-header.is-floating .mobile-menu::before {
    display: none;
  }
  
  /* Override the default menu positioning when floating */
  .site-header.is-floating .mobile-menu {
    top: auto !important;
  }
}

.mobile-menu.is-open {
  display: block;
  animation: menuSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes menuSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Floating menu popup animation */
@media (max-width: 767px) {
  .site-header.is-floating .mobile-menu.is-open {
    animation: menuPopUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@keyframes menuPopUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.mobile-menu a {
  display: block;
  padding: 0.875rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: var(--radius-control);
}

.mobile-menu a:hover {
  color: var(--signal-yellow);
  background: var(--background-primary);
}

.mobile-menu a.active {
  color: var(--signal-yellow);
  background: var(--background-primary);
  font-weight: 600;
}

.mobile-menu-inner {
  padding: 1rem 0.5rem;
}

.mobile-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 1rem 0.5rem;
}

.mobile-menu-social {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 1rem;
  margin: 0 0.5rem;
  padding: 1rem 0;
}

.mobile-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.mobile-social-link:hover {
  color: var(--signal-yellow);
}

.mobile-social-link svg {
  flex-shrink: 0;
}

.mobile-menu-actions {
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: 0.5rem;
}

/* Mobile menu backdrop blur effect - following media modal pattern */
.mobile-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--black-a30);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-menu-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Footer */
.site-footer {
  margin-top: auto;
  text-align: center;
  padding: 4rem 0;
  background: var(--background);
}

/* Signature sits above the socials so the space before the footer has a sign-off */
.footer-signature { display: block; width: 60px; height: auto; margin: 0 auto var(--space-8); color: var(--text-primary); }

.footer-social {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.social-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
}

.social-icon:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.social-icon svg {
  width: 24px;
  height: 24px;
}

.footer-copyright {
  text-align: center;
}

.footer-copyright p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9rem;
}

.footer-copyright .footer-links { margin-top: var(--space-2); }
.footer-links a { color: var(--text-secondary); }

.section {
  padding: 4rem 0;
}

.stack-2 {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.socials {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.social-link {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  transition: all 0.2s ease;
}

.social-link:hover {
  color: var(--gray-700);
  border-color: var(--gray-200);
  box-shadow: 0 2px 8px var(--black-a10);
}

/* Portfolio Grid */
.portfolio-header {
  text-align: center;
}

.portfolio-header h1 {
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.25rem;
  font-weight: 400;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.portfolio-card {
  position: relative;
  overflow: hidden;
  box-shadow: none;
  border-radius: var(--radius-surface);
  border: 1px solid var(--border-light); /* Signal yellow with 40% opacity */
  background: var(--text-primary);
  transition: all 0.3s ease;
}

.portfolio-card:hover {
  transform: translateY(-8px);
  box-shadow: none;
}

.portfolio-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.portfolio-card-image {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
}

.portfolio-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.portfolio-card:hover .portfolio-card-image img {
  transform: scale(1.1);
}

.portfolio-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background-secondary);
  font-size: 3rem;
}

.portfolio-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, transparent 0%, var(--black-a80) 100%);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

/* Ensure hover works when hovering the anchor specifically */
.portfolio-card-link:hover .portfolio-card-overlay {
  opacity: 1;
}

.portfolio-card-content {
  padding: 2rem;
  color: var(--white);
}

.portfolio-card-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
  letter-spacing: .02em;
  color: var(--signal-yellow);
}

.portfolio-card-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  margin: 0;
  line-height: 1.4;
}

/* Responsive portfolio grid */
@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .portfolio-card-content {
    padding: 1.5rem;
  }
  
  .portfolio-card-title {
    font-size: 1.25rem;
  }

  .site-footer {
    padding-bottom: 6rem;
  }
}

/* Portfolio Detail Page */
.project-header {
  text-align: left;
}

.project-title {
  margin-bottom: 1rem;
}

.project-subtitle {
  font-size: 1.25rem;
  margin-bottom: 0;
}






/* Comics Grid & Cards */
.comic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

/* Series page grid: room in the gutters for the Ben-Day dots */
/* Flex so a short last row (or a single issue) sits in the center */
.comic-strip-grid {
  --strip-gap: var(--space-6);
  --strip-columns: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-8) var(--strip-gap);
}
.comic-strip-grid > .comic-card { width: calc((100% - (var(--strip-columns) - 1) * var(--strip-gap)) / var(--strip-columns)); }
@media (min-width: 768px) { .comic-strip-grid { --strip-columns: 3; } }
@media (min-width: 1024px) { .comic-strip-grid { --strip-columns: 4; --strip-gap: var(--space-8); row-gap: var(--space-10); } }

/* Comic panel: ink border, yellow caption box, Ben-Day dots spread out behind on hover */
.comic-card {
  position: relative;
  isolation: isolate;
  box-shadow: none;
  border-radius: 0;
}

/* The panel lives on the link so the dots (::before) sit behind it */
.comic-card .comic-card-link {
  position: relative;
  height: 100%;
  background: var(--background-secondary);
  border: 2px solid var(--text-primary);
}

.comic-card::before {
  content: '';
  position: absolute;
  inset: -30%;
  z-index: -1;
  background: var(--text-primary);
  -webkit-mask: url('/media/site/benday-halo.svg') center / 100% 100% no-repeat;
  mask: url('/media/site/benday-halo.svg') center / 100% 100% no-repeat;
  clip-path: circle(0% at 50% 50%);
  transition: clip-path .5s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.comic-card:hover::before,
.comic-card:focus-within::before {
  clip-path: circle(50% at 50% 50%);
}

/* The hovered card drops below its neighbors so its halo tucks behind them */
.comic-strip-grid .comic-card { z-index: 1; }
.comic-strip-grid .comic-card:hover,
.comic-strip-grid .comic-card:focus-within { z-index: 0; }

.comic-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.comic-card-image {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  border-radius: 0;
}

.comic-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
  border-radius: 0;
}

.comic-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, transparent 0%, var(--black-a80) 100%);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.comic-card:hover .comic-card-overlay {
  opacity: 1;
}

.comic-card-content {
  padding: 2rem;
  color: var(--white);
}

/* Series page: the title is a yellow caption box inside the panel, bottom left */
.comic-card-info {
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: var(--space-3);
  padding: 0;
}

.comic-card-info .comic-card-title {
  display: inline-block;
  margin: 0;
  padding: var(--space-1) var(--space-3);
  background: var(--signal-yellow);
  border: 2px solid var(--text-primary);
  box-shadow: 3px 3px 0 var(--text-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.35;
  text-transform: uppercase;
  transition: transform .25s ease, box-shadow .25s ease;
}

.comic-card:hover .comic-card-title,
.comic-card:focus-within .comic-card-title {
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0 var(--text-primary);
}

@media (max-width: 768px) {
  .comic-card-info { left: var(--space-2); right: var(--space-2); bottom: var(--space-2); }
  .comic-card-info .comic-card-title { font-size: 11px; padding: 2px var(--space-2); }
}

@media (prefers-reduced-motion: reduce) {
  .comic-card::before, .comic-card-info .comic-card-title { transition: none; }
}

.comic-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}

.comic-card-genre {
  font-size: 0.95rem;
  opacity: 0.9;
  margin: 0;
}

.comic-placeholder {
  width: 100%;
  height: 100%;
  background: var(--background-secondary);
  display: grid;
  place-items: center;
  border-radius: 0;
}

.comic-placeholder-text {
  color: inherit;
  font-weight: 600;
}

/* Comic detail */
.comics-single .prose img {
  border-radius: 0;
}

.comic-topdown-image {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 1rem;
  border-radius: 0;
}

.comic-carousel {
  position: relative;
  height: 70vh;
  max-height: 800px;
  min-height: 500px;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--background-primary);
  margin: 2rem 0;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
}

.comic-carousel-track {
  display: flex;
  transition: transform 0.3s ease;
  height: 100%;
  align-items: center;
  width: 100%;
}

.comic-carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.comic-carousel-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.comic-carousel-nav {
  --comic-page-size: 18px;   /* component tokens: page square and arrow hit area */
  --comic-arrow-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

/* Page squares read like a row of comic panels: open when unread, inked when selected */
.comic-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.comic-page-square {
  width: var(--comic-page-size);
  height: var(--comic-page-size);
  padding: 0;
  background: var(--background-secondary);
  border: 2px solid var(--text-primary);
  border-radius: 0;
  cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}
.comic-page-square:hover { transform: translateY(-2px); }
.comic-page-square[aria-current="true"] { background: var(--text-primary); }

.comic-nav-arrow {
  display: grid;
  place-items: center;
  width: var(--comic-arrow-size);
  height: var(--comic-arrow-size);
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  cursor: pointer;
}
.comic-nav-arrow svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: square; stroke-linejoin: miter; }
.comic-nav-arrow:disabled { opacity: .25; cursor: default; }

@media (max-width: 768px) {
  .comic-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .comic-card-content {
    padding: 1.5rem;
  }
  
  .comic-carousel {
    height: 60vh;
    max-height: 600px;
    min-height: 400px;
  }
  
}

/* Home page specific hero styling */
.home .hero {
  max-width: 85%;
  margin-bottom: 10rem;
}

@media (min-width: 768px) {
  .home .hero-subtitle {
    margin-bottom: 4rem;
  }
}

/* Home: Product sections with image/text split */
.product {
  display: grid;
  gap: 2rem;
  align-items: center;
  margin: 12rem 0;
}

/* Home: the closing section is the last thing before the footer, so it drops its bottom margin */
.home .product:last-of-type { margin-bottom: 0; }

/* Neutralize global prose image margins inside product blocks */
.product img {
  margin: 0;
  display: block;
  width: 100%;
  height: auto;
}

.product figure { margin: 0; }

/* Optional semantic wrappers if present */
/* Intentionally no base styles; selectors used for layout targeting only */

@media (min-width: 1024px) {
  /* Two-column layout at desktop */
  .product {
    grid-template-columns: 1.1fr 1fr;
  }

  /* Image on the right, content on the left */
  .product.img-right .product-content { grid-column: 1; }
  .product.img-right .product-image,
  .product.img-right .product-media { grid-column: 2; justify-self: end; }

  /* Fallbacks when wrappers aren't used: target direct children */
  .product.img-right > img,
  .product.img-right > figure { grid-column: 2; justify-self: end; }
  .product.img-right > :not(img):not(figure):not(.product-image):not(.product-media) { grid-column: 1; }
}

/* Mirror layout: image on the left, content on the right */
@media (min-width: 1024px) {
  .product.img-left .product-image,
  .product.img-left .product-media { grid-column: 1; justify-self: start; }
  .product.img-left .product-content { grid-column: 2; }

  .product.img-left > img,
  .product.img-left > figure { grid-column: 1; justify-self: start; }
  .product.img-left > :not(img):not(figure):not(.product-image):not(.product-media) { grid-column: 2; }
}

/* Centered layout: image stacked above text on all sizes */
.product.img-center {
  grid-template-columns: 1fr;
}

.product.img-center .product-image,
.product.img-center .product-media,
.product.img-center > img,
.product.img-center > figure {
  grid-column: 1;
  justify-self: center;
  max-width: 900px;
}

.product.img-center .product-content,
.product.img-center > :not(img):not(figure):not(.product-image):not(.product-media) {
  grid-column: 1;
}

/* Compact centered content for img-center */
.product.img-center .product-content,
.product.img-center > :not(img):not(figure):not(.product-image):not(.product-media):not(.product-carousel):not(.product-carousel-shell) {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* Product carousel (CSS-only, horizontal scroll) */
.product-carousel {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: .5rem;
  position: relative;
}

/* Center and cap width in img-center variant */
.product.img-center .product-carousel {
  width: 100vw;
  max-width: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.product-carousel-track {
  display: flex;
  gap: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
}

/* Trailing spacer: end padding on a scroller (or its track) is not rendered
   past overflowing content, so trailing space needs to be a real box */
.product-carousel-track::after {
  content: '';
  flex: 0 0 max(1rem, env(safe-area-inset-right));
}

.product-carousel-track .product-carousel-slide {
  flex: 0 0 min(260px, 70%);
}

@media (min-width: 768px) {
  .product-carousel-track .product-carousel-slide {
    flex-basis: min(320px, 55%);
  }
}

@media (min-width: 1280px) {
  .product-carousel-track .product-carousel-slide {
    flex-basis: min(420px, 45%);
  }
}

.product-carousel-slide {
  border-radius: var(--radius-md);
  corner-shape: squircle;
  overflow: hidden;
  scroll-snap-align: center;
}

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

/* Carousel shell: positioning context for the nav arrows */
.product-carousel-shell {
  position: relative;
}

/* Carousel nav arrows */
.product-carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: var(--white-a72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--black-a12);
  transition: opacity .25s ease, transform .15s ease;
  z-index: 1;
}

.product-carousel-nav:hover:not([disabled]) {
  transform: translateY(-50%) scale(1.06);
}

.product-carousel-nav:focus-visible {
  outline: 2px solid var(--signal-yellow);
  outline-offset: 2px;
}

/* Paddles fade away at the ends */
.product-carousel-nav[disabled] {
  opacity: 0;
  pointer-events: none;
}

.product-carousel-nav.prev { left: 1rem; }
.product-carousel-nav.next { right: 1rem; }

/* Touch screens scroll by swipe */
@media (max-width: 767px) {
  .product-carousel-nav { display: none; }
}

/* Hide scrollbar where supported */
.product-carousel { scrollbar-width: none; }
.product-carousel::-webkit-scrollbar { display: none; }

/* Home: work grid (image with title and tag in the lower left) */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
  gap: var(--space-8);
}

.work-tile {
  position: relative;
  display: block;
  aspect-ratio: 4/3;
  border-radius: var(--radius-surface);
  corner-shape: squircle;
  overflow: hidden;
  background: var(--background-tertiary);
  color: inherit;
  text-decoration: none;
}

.work-tile-image { position: absolute; inset: 0; }
.work-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
a.work-tile:hover .work-tile-image img { transform: scale(1.04); }

.work-tile-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-16) var(--space-6) var(--space-5);
  /* Strong enough for white text on light images */
  background: linear-gradient(to top, var(--black-a80) 0%, var(--black-a55) 45%, transparent 100%);
  color: var(--white);
  opacity: 0;
  transition: opacity .2s ease;
}

/* Title and shade show on hover or keyboard focus. Touch screens (no hover) and
   tiles still waiting for an image always show them. */
.work-tile:hover .work-tile-caption,
.work-tile:focus-visible .work-tile-caption,
.work-tile-image:not(:has(img)) + .work-tile-caption { opacity: 1; }
@media (hover: none) {
  .work-tile-caption { opacity: 1; }
}

.work-tile-title {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--white);
  margin: 0 0 var(--space-1);
}

.work-tile-tag {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--white-a90);
  margin: 0;
}

/* Project page: role line, labeled image groups, more work thumbnails */
.project-role {
  margin: var(--space-4) 0 var(--space-12);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-muted);
}
.project-role strong { font-weight: 600; color: var(--text-primary); }

.project-group { margin: 0 0 var(--space-16); }

.project-group-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
}

.project-group-image {
  position: relative;
  aspect-ratio: 16/10;
  border-radius: var(--radius-2xl);
  corner-shape: squircle;
  /* Case study images sit on pastel panels, shown whole; top-down fade like the home tiles, hues cycle down the page */
  --panel-hue: var(--panel-bg, var(--background-tertiary));
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--panel-hue) 90%, var(--white)) 0%,
    color-mix(in srgb, var(--panel-hue) 40%, var(--white)) 100%); /* bottom keeps enough hue to read against the page */
}
.prose section.project-group:nth-of-type(6n+1) { --panel-bg: var(--tile-prism-sky); }
.prose section.project-group:nth-of-type(6n+2) { --panel-bg: var(--tile-prism-mint); }
.prose section.project-group:nth-of-type(6n+3) { --panel-bg: var(--tile-prism-lemon); }
.prose section.project-group:nth-of-type(6n+4) { --panel-bg: var(--tile-prism-peach); }
.prose section.project-group:nth-of-type(6n+5) { --panel-bg: var(--tile-prism-rose); }
.prose section.project-group:nth-of-type(6n)   { --panel-bg: var(--tile-prism-lilac); }
.project-group-image img { display: block; width: 100%; height: auto; margin: 0; border-radius: var(--radius-control); filter: drop-shadow(var(--shadow-art-md)); }
.project-group-image:has(img) { aspect-ratio: auto; display: grid; place-items: center; padding: var(--space-10) var(--space-8); }

.project-group-caption {
  /* Lead-in treatment at caption size: dark first sentence, muted rest */
  margin: var(--space-3) 0 0;
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-muted);
}
.project-group-caption strong { font-weight: 600; color: var(--text-primary); }

/* A titled section inside a case study (e.g. StoryboardKit "Built from components") */
.prose .project-section-title { margin: var(--space-20) 0 var(--space-4); }
.prose .project-section-intro { max-width: 36em; margin-bottom: var(--space-12); font-size: var(--text-lg); color: var(--text-secondary); }

/* Split panels float the art on the page (Apple-style): no gray panel, no card shadow,
   and white in the image blends into the page background */
.project-group--split .project-group-image { background: none; }
.project-group--split .project-group-image:has(img) { padding: 0; }
.project-group--split .project-group-image img { filter: none; border-radius: 0; mix-blend-mode: multiply; }

/* Split panel (Apple-style feature row): image on one side, the caption as a headline and
   short paragraph on the other. --flip puts the image on the right. Stacks on narrow screens. */
@media (min-width: 900px) {
  .project-group--split {
    --split-width: min(1080px, calc(100vw - 2 * var(--space-8)));
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto auto 1fr;
    grid-template-areas: "image ." "image label" "image caption" "image .";
    column-gap: var(--space-12);
    width: var(--split-width);
    margin-left: calc(50% - var(--split-width) / 2); /* wider than the text column, centered */
  }
  .project-group--split.project-group--flip {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    grid-template-areas: ". image" "label image" "caption image" ". image";
  }
  .project-group--split .project-group-label { grid-area: label; }
  .project-group--split .project-group-image { grid-area: image; }
  .project-group--split .project-group-caption {
    grid-area: caption;
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 400;
    line-height: 1.5;
  }
  .project-group--split .project-group-caption strong {
    display: block;
    margin-bottom: var(--space-3);
    font-family: var(--font-heading);
    font-size: var(--h3-size);
    font-weight: 600;
    line-height: 1.2;
  }
}

.more-work {
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: var(--border-1) solid var(--border-light);
}

.more-work .more-work-heading {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-4);
}

.work-grid--small {
  grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 30%, 240px), 1fr));
  gap: var(--space-4);
}
.work-grid--small .work-tile-caption { padding: var(--space-8) var(--space-4) var(--space-3); }
.more-work .work-grid--small .work-tile-title {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin: 0;
}
.more-work .work-tile-image img { margin: 0; border-radius: 0; height: 100%; }

.home .page-body .page-content { padding-top: 0; }
.home .page-body .page-content > p:empty { display: none; }

/* Home: closing line under "But that's not all I do." */
.home .product-content h3 {
  font-size: var(--text-lg);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--text-secondary);
}

/* Empty image state: small image icon centered in the gray area */
.work-tile-image:not(:has(img))::before,
.project-group-image:not(:has(img))::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E") center / 40px no-repeat;
}
.work-grid--small .work-tile-image:not(:has(img))::before { background-size: 28px; }
/* Work under NDA: lock icon instead of the image icon */
.is-locked:not(:has(img))::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E"); }

/* Apps page: short intro under the subtitle */
.apps-intro {
  max-width: 40rem;
  margin: var(--space-4) auto 0;
  font-size: var(--text-base);
  color: var(--text-muted);
}

/* ---------- Home: feature tiles (title and pitch on a gradient, art below) ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.feature-tile {
  --tile-bg: var(--gray-100);
  --tile-ink: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 560px;
  padding: var(--space-12) var(--space-6) 0;
  border-radius: var(--radius-surface);
  corner-shape: squircle;
  overflow: hidden;
  background: var(--tile-bg);
  color: var(--tile-ink);
  text-align: center;
  text-decoration: none;
}
.feature-tile-text { display: grid; justify-items: center; }
.home .feature-tile-title { margin: 0 0 var(--space-2); font-size: clamp(2rem, 3.2vw, 2.75rem); line-height: 1.05; color: inherit; }
.feature-tile-line { max-width: 22em; margin: 0 0 var(--space-4); font-size: var(--text-lg); line-height: 1.4; color: inherit; opacity: .85; }
/* Cue is the site's soft button, tinted to sit on the gradient */
.feature-tile {
  --btn-soft-bg: var(--white-a60);
  --btn-soft-bg-hover: var(--white-a95);
}
.feature-tile--ink {
  --btn-soft-bg: var(--white-a14);
  --btn-soft-bg-hover: var(--white-a26);
}
.feature-tile .feature-tile-cta { color: inherit; }
.feature-tile:hover .feature-tile-cta, .feature-tile:focus-visible .feature-tile-cta { background-color: var(--btn-soft-bg-hover); }
.feature-tile:focus-visible { outline: 3px solid var(--text-primary); outline-offset: 3px; }

/* Art area: an icon for now; product images drop in here later (shown whole, not cropped) */
.feature-tile-art { flex: 1; display: grid; place-items: center; width: 100%; padding: var(--space-8) 0; transition: transform .4s ease; }
.feature-tile:hover .feature-tile-art { transform: scale(1.04); }
.feature-tile-art img { max-width: 86%; max-height: 300px; object-fit: contain; margin: 0; border-radius: var(--radius-control); filter: drop-shadow(var(--shadow-art)); }
.feature-tile-icon { width: 128px; height: 128px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }

/* Home tiles: bluish grays that fade from the top down, one dark tile */
.feature-tile--pebble { --tile-bg: linear-gradient(180deg, var(--tile-pebble) 0%, var(--tile-pebble-end) 70%); }
.feature-tile--mist   { --tile-bg: linear-gradient(180deg, var(--tile-mist) 0%, var(--tile-mist-end) 75%); }
.feature-tile--dusk   { --tile-bg: linear-gradient(180deg, var(--tile-dusk) 0%, var(--tile-dusk-end) 75%); }
.feature-tile--prism  { --tile-bg: linear-gradient(180deg, transparent 0%, var(--white-a70) 80%), linear-gradient(115deg, var(--tile-prism-rose), var(--tile-prism-peach) 20%, var(--tile-prism-lemon) 38%, var(--tile-prism-mint) 58%, var(--tile-prism-sky) 78%, var(--tile-prism-lilac)); }
.feature-tile--sun    { --tile-bg: linear-gradient(180deg, var(--tile-sun) 0%, var(--tile-sun-end) 75%); }
.feature-tile--ink    { --tile-bg: linear-gradient(180deg, var(--tile-ink-bg) 0%, var(--tile-ink-bg-end) 100%); --tile-ink: var(--white); }

@media (max-width: 768px) {
  .feature-grid { grid-template-columns: 1fr; }
  .feature-tile { min-height: 440px; padding-top: var(--space-10); }
  .feature-tile-icon { width: 104px; height: 104px; }
}

/* More work: bottom gradient in the home page's soft bluish tones, ink titles */
.more-work .work-tile-caption {
  background: linear-gradient(to top, var(--pebble-a97) 0%, var(--pebble-a85) 45%, transparent 100%);
  color: var(--text-primary);
}
.more-work .work-tile:nth-child(even) .work-tile-caption {
  background: linear-gradient(to top, var(--mist-a97) 0%, var(--mist-a85) 45%, transparent 100%);
}
.more-work .work-grid--small .work-tile-title { color: var(--text-primary); }

/* Tiles are links but never get the yellow link underline, even inside .prose */
a.work-tile, a.work-tile:hover, a.work-tile:focus,
.prose a.work-tile, .prose a.work-tile:hover, .prose a.work-tile:focus,
a.feature-tile, a.feature-tile:hover, a.feature-tile:focus {
  box-shadow: none;
}

/* Comics tile: the other series covers fan out behind the Vongfai cover (opened by initComicFan in app.js) */
.comic-fan { --fan-height: 240px; }
.comic-fan-stack { position: relative; display: block; height: var(--fan-height); aspect-ratio: 2 / 3; }
.feature-tile-art .comic-fan-cover { position: relative; z-index: 10; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; }
.comic-fan-pages img {
  position: absolute;
  inset: 0;
  z-index: calc(10 - var(--d));
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  transform-origin: 50% 75%;
  transform: scale(.94);
  filter: drop-shadow(var(--shadow-art-sm));
  transition: transform 1s cubic-bezier(.2, .8, .2, 1) calc(var(--d) * 70ms);
}
.comic-fan.is-open .comic-fan-pages img { transform: translateX(calc(var(--i) * 20px)) rotate(calc(var(--i) * 15deg)) scale(.96); }
.feature-tile:hover .comic-fan.is-open .comic-fan-pages img { transform: translateX(calc(var(--i) * 22px)) rotate(calc(var(--i) * 16deg)) scale(.96); transition-delay: 0s; }
@media (max-width: 768px) {
  .comic-fan { --fan-height: 180px; }
  .comic-fan.is-open .comic-fan-pages img, .feature-tile:hover .comic-fan.is-open .comic-fan-pages img { transform: translateX(calc(var(--i) * 12px)) rotate(calc(var(--i) * 14deg)) scale(.96); }
}
@media (prefers-reduced-motion: reduce) {
  .comic-fan-pages img { transition: none; }
}
