/* --------------------------------------------------------------------------
   Kai Westphal — Portfolio
   Emil-inspired type layout + Levon-inspired horizontal project gallery
   -------------------------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --text: #111111;
  --text-muted: #8a8a8a;
  --text-soft: #a3a3a3;
  --border-soft: rgba(0, 0, 0, 0.06);
  --card-bg: #f4f4f5;
  --frame-bg: #f7f7f8;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.06);

  /* Fluid type + spacing that scale with viewport width */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  --text-base: clamp(0.95rem, 0.9rem + 0.25vw, 1.0625rem);
  --text-sm: clamp(0.875rem, 0.84rem + 0.15vw, 0.95rem);
  --text-lg: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
  --text-title: clamp(1.05rem, 1rem + 0.25vw, 1.15rem);

  --leading: 1.65;
  --leading-tight: 1.35;

  /* Content column scales with width, caps for readability */
  --content-max: min(36rem, 92vw);
  --page-pad-x: clamp(1.25rem, 4vw, 2.5rem);
  --page-pad-y: clamp(3.5rem, 10vw, 7rem);
  --section-gap: clamp(3rem, 8vw, 5.5rem);
  /* Shared gap: section title → content below it (Today text / project images) */
  --title-content-gap: 1.1em;

  /* Gallery cards — square swipe tiles that scale with width */
  --card-w: clamp(17rem, 48vw, 26rem);
  --gallery-gap: clamp(1rem, 2.4vw, 1.5rem);
  --gallery-radius: clamp(0.85rem, 1.8vw, 1.25rem);
  --gallery-pad-x: max(
    var(--page-pad-x),
    calc((100vw - var(--content-max)) / 2)
  );
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading);
  color: var(--text-muted);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Views swap in-place (no full page reload / white flash) */
.view[hidden] {
  display: none !important;
}

.view.is-active {
  display: block;
}

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

a {
  color: inherit;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Page shell — centered content column that grows with width
   -------------------------------------------------------------------------- */

.page {
  width: 100%;
  max-width: calc(var(--content-max) + var(--page-pad-x) * 2);
  margin: 0 auto;
  padding: var(--page-pad-y) var(--page-pad-x) 0;
}

.page-bottom {
  padding-top: var(--section-gap);
  padding-bottom: var(--page-pad-y);
}

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

.header {
  margin-bottom: var(--section-gap);
}

.name {
  margin: 0;
  font-size: var(--text-title);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: var(--leading-tight);
}

.role {
  margin: 0.2em 0 0;
  font-size: var(--text-title);
  font-weight: 400;
  color: var(--text-muted);
  line-height: var(--leading-tight);
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

.section {
  margin-bottom: var(--section-gap);
}

.section:last-child {
  margin-bottom: 0;
}

.section-title {
  margin: 0 0 var(--title-content-gap);
  font-size: var(--text-title);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: var(--leading-tight);
}

.prose p {
  margin: 0 0 1.1em;
  max-width: 40em;
}

.prose p:last-child {
  margin-bottom: 0;
}

.inline-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: opacity 0.15s ease;
}

/* Projects title → images: same gap as Today title → body */
.section-projects {
  margin-bottom: 0;
}

.section-projects .section-title {
  margin-bottom: var(--title-content-gap);
}

/* Kill default section bottom gap so only --title-content-gap remains */
.page .section-projects {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Horizontal gallery (Levon-style)
   -------------------------------------------------------------------------- */

.gallery-section {
  width: 100%;
  margin: 0 0 clamp(1rem, 3vw, 2rem);
  /* Full-bleed relative to viewport */
}

.gallery-track {
  display: flex;
  gap: var(--gallery-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-padding-inline: var(--gallery-pad-x);
  /* No top padding so Projects → images gap matches Today → text */
  padding: 0 var(--gallery-pad-x) 1.25rem;
  /* Native two-finger / touch scroll only — no drag cursor */
  cursor: default;
  scrollbar-width: none;
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

.gallery-card {
  flex: 0 0 auto;
  width: var(--card-w);
  scroll-snap-align: start;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

/* Non-linked images on project detail */
.gallery-card--static {
  cursor: default;
  pointer-events: none;
}

/* Square images — no border, outline, or shadow */
.gallery-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  border-radius: var(--gallery-radius);
  border: none;
  outline: none;
  box-shadow: none;
  background: #ececee;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-meta {
  margin-top: clamp(0.85rem, 2vw, 1.1rem);
  padding-inline: 0.15rem;
}

.gallery-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.gallery-subtitle {
  margin: 0.15em 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.35;
}

/* --------------------------------------------------------------------------
   Project detail
   -------------------------------------------------------------------------- */

.page-project {
  padding-bottom: 0;
}

.page-project-bottom {
  /* Comfortable gap under the image gallery (between too tight and too airy) */
  padding-top: clamp(1.35rem, 3vw, 2rem);
  /* Extra space under “Back to home” before the page edge */
  padding-bottom: clamp(5rem, 12vw, 8.5rem);
}

.header-project {
  margin-bottom: var(--title-content-gap);
}

.project-detail-title {
  margin: 0;
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: var(--leading-tight);
}

.project-detail-subtitle {
  margin: 0.35em 0 0;
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--text-muted);
  line-height: var(--leading-tight);
}

/* External project link — quiet chip under the gallery */
.project-detail-link {
  margin: 0 0 clamp(1.35rem, 2.8vw, 1.85rem);
}

.project-detail-link[hidden] {
  display: none;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.55em 0.95em 0.55em 1em;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

.project-link-arrow {
  display: inline-block;
  font-size: 0.95em;
  line-height: 1;
  opacity: 0.55;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease;
}

/* Match home: title → gallery gap */
.gallery-section-detail {
  margin-top: 0;
  margin-bottom: 0;
}

.gallery-section-detail .gallery-track {
  padding-bottom: 0.5rem;
}

/* Summary → body: a bit of air, not a full section gap */
.project-summary {
  margin-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
}

.project-lead {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text);
  line-height: var(--leading);
  max-width: 40em;
}

.project-body {
  margin-bottom: 0;
  color: var(--text-muted);
}

.project-body.prose p:first-child {
  margin-top: 0;
}

.project-home-link {
  margin: clamp(2rem, 5vw, 3rem) 0 clamp(0.5rem, 1vw, 1rem);
}

/* --------------------------------------------------------------------------
   Bottom stack: Capabilities / Contact
   Same title → content gap as Contact / Location / Media
   -------------------------------------------------------------------------- */

.capabilities-section .section-title,
.info-block .section-title {
  margin-bottom: 0.45em;
}

.capabilities-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: var(--leading);
}

.capabilities-list li {
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Contact / Location / Media
   -------------------------------------------------------------------------- */

.contact-section {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.info-value {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-muted);
}

.media-list,
.background-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
}

.contact-note {
  margin: 2.25em 0 0;
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: var(--leading);
  max-width: 40em;
}

.background-list {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: var(--leading);
}

.link {
  color: var(--text-muted);
  transition: color 0.15s ease, opacity 0.15s ease;
}

/* Email row: not a link — same look as muted text links, no URL chrome */
.copy-email-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.55em;
}

button.copy-email {
  appearance: none;
  -webkit-appearance: none;
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

button.copy-email:focus,
button.copy-email:focus-visible {
  outline: none;
  box-shadow: none;
  background: none;
}

/* Hover only when a real pointer exists (not phones / touch) */
@media (hover: hover) and (pointer: fine) {
  .inline-link:hover {
    opacity: 0.65;
  }

  a.gallery-card:hover {
    opacity: 0.88;
  }

  a.gallery-card:active {
    opacity: 0.75;
  }

  .project-link:hover {
    border-color: rgba(0, 0, 0, 0.28);
    background: rgba(0, 0, 0, 0.035);
  }

  .project-link:active {
    background: rgba(0, 0, 0, 0.06);
  }

  .project-link:hover .project-link-arrow {
    opacity: 0.9;
    transform: translateX(2px);
  }

  .link:hover {
    color: var(--text);
  }

  button.copy-email:hover {
    color: var(--text);
    background: none;
    border: none;
    box-shadow: none;
  }
}

/* Match email type exactly; only opacity is animated */
.copy-toast {
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.copy-email-row.is-copied .copy-toast {
  opacity: 1;
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .copy-toast {
    transition: opacity 0.15s ease;
    transform: none;
  }

  .copy-email-row.is-copied .copy-toast {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Focus & accessibility
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
  border-radius: 2px;
}

.gallery-track:focus-visible {
  outline-offset: -2px;
}

/* --------------------------------------------------------------------------
   Mobile refinements
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  :root {
    --content-max: 100%;
    --page-pad-x: 1.65rem;
    --card-w: min(78vw, 22rem);
    --gallery-pad-x: var(--page-pad-x);
    /* Larger type on small screens */
    --text-base: 1.08rem;
    --text-sm: 0.98rem;
    --text-title: 1.15rem;
  }

  .page {
    padding-top: clamp(2.5rem, 12vw, 4rem);
  }

  .gallery-track {
    scroll-snap-type: x proximity;
  }
}

/* Wide screens: readable text column, slightly larger tiles */
@media (min-width: 1100px) {
  :root {
    --content-max: min(38rem, 40vw);
    --card-w: clamp(22rem, 30vw, 28rem);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .gallery-card,
  .inline-link,
  .link,
  .project-link,
  .project-link-arrow {
    transition: none;
  }
}
