/* ========================================
   Jussi Ängeslevä — Portfolio
   style.css
   ======================================== */

/* Reset & base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: #ffffff;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  line-height: 1.5;
}

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

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

/* ----------------------------------------
   Header
   ---------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 40px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-name {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-name a {
  color: #1a1a1a;
}

.header-tagline {
  font-size: 17px;
  line-height: 1.6;
  color: rgba(0, 0, 0, 0.45);
  font-weight: 300;
  max-width: 600px;
}

.header-nav {
  display: flex;
  gap: 28px;
  align-items: center;
  padding-top: 6px;
}

.header-nav a {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.4);
  transition: color 0.2s;
}

.header-nav a:hover {
  color: #1a1a1a;
}

/* ----------------------------------------
   Bio tagline
   ---------------------------------------- */
/* Bio tagline is now in .header-tagline */

/* ----------------------------------------
   Category filter
   ---------------------------------------- */
.filter {
  display: flex;
  gap: 32px;
  padding: 0 40px 32px;
}

.filter-tab {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  padding-bottom: 6px;
  border: none;
  border-bottom: 2px solid transparent;
  transition: all 0.25s;
  background: none;
  font-family: inherit;
}

.filter-tab:hover {
  color: rgba(0, 0, 0, 0.7);
}

.filter-tab.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

/* ----------------------------------------
   Project grid — variable sizing
   ---------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  /* Uniform row height: 3/4 of one column width → 4:3 ratio for 1×1 tiles */
  grid-auto-rows: calc((100vw - 80px - 6px) / 4 * 3 / 4);
  gap: 2px;
  padding: 0 40px 80px;
}

/* ----------------------------------------
   Card sizes
   ---------------------------------------- */
.card {
  display: block;
  position: relative;
  overflow: hidden;
  transition: opacity 0.3s;
}

/* Default: 1×1 */
.card {
  grid-column: span 1;
  grid-row: span 1;
  height: 100%;
}

/* Wide: spans 2 columns */
.card.card-wide {
  grid-column: span 2;
}

/* Tall: spans 2 rows */
.card.card-tall {
  grid-row: span 2;
}

/* Large: spans 2 columns × 2 rows */
.card.card-large {
  grid-column: span 2;
  grid-row: span 2;
}

.card.hidden {
  display: none;
}

.card-image-wrap {
  overflow: hidden;
  background: #f0f0f0;
  position: relative;
  height: 100%;
}

/* Tall & large project cards: grid handles sizing via grid-auto-rows */

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card:hover .card-image-wrap img {
  transform: scale(1.04);
}

/* Title overlay on image */
.card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 16px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 2;
  pointer-events: none;
}

.card-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 2px;
  color: #ffffff;
}

.card-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 300;
  letter-spacing: 0.02em;
}

.card-meta span + span::before {
  content: '\00b7';
  margin: 0 6px;
  color: rgba(255, 255, 255, 0.4);
}

/* ----------------------------------------
   Text tiles
   ---------------------------------------- */
.tile-text {
  display: flex;
  align-items: center;
  padding: 24px;
  background: #f5f5f5;
}

.tile-text.card-wide {
  grid-column: span 2;
}

.tile-text.card-tall {
  grid-row: span 2;
}

.tile-text.card-large {
  grid-column: span 2;
  grid-row: span 2;
}

.tile-text-inner {
  max-width: 100%;
}

.tile-text-inner h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  color: #1a1a1a;
}

.tile-text-inner h3 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1a1a1a;
}

.tile-text-inner p {
  font-size: 20px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.6);
  font-weight: 400;
}

.tile-text-inner p + p {
  margin-top: 8px;
}

.tile-text-inner em {
  font-style: italic;
}

.tile-text-inner strong {
  font-weight: 600;
  color: #1a1a1a;
}

.tile-text-inner a {
  color: rgba(0, 0, 0, 0.5);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

.tile-text-inner a:hover {
  color: #1a1a1a;
}

.tile-text.hidden {
  display: none;
}

/* ----------------------------------------
   Detail page
   ---------------------------------------- */
.detail-back {
  padding: 16px 40px 20px;
}

.detail-back a {
  font-size: 14px;
  color: rgba(0, 0, 0, 0.35);
  font-weight: 400;
  transition: color 0.2s;
}

.detail-back a:hover {
  color: #1a1a1a;
}

/* Detail grid: no fixed row height — content-driven */
.detail-grid {
  grid-auto-rows: auto;
  padding-bottom: 0;
}

.detail-hero {
  grid-column: span 4;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  max-height: 70vh;
}

.detail-hero img,
.detail-hero video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-title {
  grid-column: span 2;
  padding: 32px 0 24px;
}

.detail-title h1 {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 10px;
  color: #1a1a1a;
}

.detail-subtitle {
  font-size: 17px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.45);
  font-weight: 300;
  margin-bottom: 6px;
}

.detail-meta {
  font-size: 14px;
  color: rgba(0, 0, 0, 0.35);
  font-weight: 400;
}

.detail-text {
  grid-column: span 2;
  padding: 24px 0 32px;
}

.detail-text p {
  font-size: 16px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.65);
  font-weight: 300;
  margin-bottom: 16px;
  max-width: 65ch;
}

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

/* Detail media tiles */
.detail-media {
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: #f0f0f0;
}

.detail-media img,
.detail-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.detail-media:hover img {
  transform: scale(1.03);
}

.detail-media.span-2 {
  grid-column: span 2;
}

.detail-media.span-4 {
  grid-column: span 4;
}

/* Video play button */
.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #1a1a1a;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  transition: opacity 0.3s;
}

.detail-media video.playing ~ .video-play-btn {
  opacity: 0;
}

/* Credits */
.detail-credits {
  grid-column: span 4;
  padding: 32px 0 40px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.detail-credits p {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.3);
  font-weight: 300;
  font-style: italic;
}

.detail-credits p + p {
  margin-top: 4px;
}

/* Prev/Next navigation */
.detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 40px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.detail-nav a {
  font-size: 15px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.4);
  transition: color 0.2s;
}

.detail-nav a:hover {
  color: #1a1a1a;
}

.detail-nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.25);
  margin-bottom: 4px;
}

.detail-nav-title {
  font-size: 16px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.5);
}

/* Fullscreen overlay */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
}

.fullscreen-overlay.active {
  display: flex;
}

.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: color 0.2s;
}

.fullscreen-close:hover {
  color: #ffffff;
}

.fullscreen-prev,
.fullscreen-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.7);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: background 0.2s, color 0.2s;
}

.fullscreen-prev:hover,
.fullscreen-next:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.fullscreen-prev { left: 24px; }
.fullscreen-next { right: 24px; }

.fullscreen-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-content img,
.fullscreen-content video {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
}

/* ----------------------------------------
   Footer
   ---------------------------------------- */
.footer {
  padding: 40px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-left {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.3);
  font-weight: 300;
}

.footer-right {
  display: flex;
  gap: 24px;
}

.footer-right a {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.3);
  font-weight: 300;
  transition: color 0.2s;
}

.footer-right a:hover {
  color: rgba(0, 0, 0, 0.7);
}

/* ----------------------------------------
   Back to top
   ---------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.5);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, background 0.2s;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* ----------------------------------------
   Responsive: tablet (<=1024px)
   ---------------------------------------- */
@media (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: calc((100vw - 48px - 2px) / 2 * 3 / 4);
    padding: 0 24px 60px;
  }

  /* On tablet, large cards still span 2 cols but only 1 row */
  .card.card-large {
    grid-column: span 2;
    grid-row: span 1;
  }

  /* Wide cards fill the full row on 2-col */
  .card.card-wide {
    grid-column: span 2;
  }

  /* Tall text tiles collapse to 1×1 on 2-col layout */
  .tile-text.card-tall {
    grid-row: span 1;
  }

  /* Detail page: content-driven row heights on tablet */
  .detail-grid { grid-auto-rows: auto; }
  .detail-hero { grid-column: span 2; max-height: 50vh; }
  .detail-title { grid-column: span 2; }
  .detail-text { grid-column: span 2; }
  .detail-media.span-2 { grid-column: span 2; }
  .detail-media.span-4 { grid-column: span 2; }
  .detail-credits { grid-column: span 2; }
  .detail-back { padding: 12px 24px 16px; }
  .detail-nav { padding: 24px; }

  .header {
    padding: 20px 24px;
  }

  .header-name {
    font-size: 24px;
  }

  .header-tagline {
    font-size: 15px;
  }

  .filter {
    padding: 0 24px 24px;
  }

  .footer {
    padding: 32px 24px;
  }
}

/* ----------------------------------------
   Responsive: mobile (<=600px)
   ---------------------------------------- */
@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr;
    grid-auto-rows: calc((100vw - 32px) * 10 / 16);
    gap: 2px;
    padding: 0 16px 40px;
  }

  /* All cards become single column on mobile */
  .card.card-wide,
  .card.card-tall,
  .card.card-large {
    grid-column: span 1;
    grid-row: span 1;
  }

  /* Detail page: everything stacks, content-driven rows */
  .detail-grid { grid-auto-rows: auto; }
  .detail-hero,
  .detail-title,
  .detail-text,
  .detail-media,
  .detail-media.span-2,
  .detail-media.span-4,
  .detail-credits { grid-column: span 1; }
  .detail-hero { max-height: 40vh; }
  .detail-title h1 { font-size: 28px; }
  .detail-back { padding: 12px 16px 16px; }
  .detail-nav { padding: 24px 16px; flex-direction: column; gap: 16px; align-items: flex-start; }

  .header {
    padding: 16px;
  }

  .header-name {
    font-size: 22px;
  }

  .header-tagline {
    font-size: 14px;
  }

  .filter {
    padding: 0 16px 20px;
    gap: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filter-tab {
    white-space: nowrap;
  }

  .card-title {
    font-size: 14px;
  }

  .card-info {
    padding: 10px 2px 24px;
  }

  .footer {
    padding: 24px 16px;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
}

/* ----------------------------------------
   About page
   ---------------------------------------- */
.about {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

.about-intro {
  display: flex;
  gap: 40px;
  margin-bottom: 64px;
}

.about-portrait {
  flex: 0 0 240px;
}

.about-portrait img {
  width: 100%;
  border-radius: 4px;
}

.about-bio h1 {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 6px;
}

.about-title {
  font-size: 17px;
  color: rgba(0, 0, 0, 0.45);
  font-weight: 300;
  margin-bottom: 20px;
}

.about-bio p {
  font-size: 16px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.65);
  font-weight: 300;
}

.about-contact {
  margin-top: 16px;
}

.about-contact a {
  color: rgba(0, 0, 0, 0.45);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

.about-contact a:hover {
  color: #1a1a1a;
}

/* CV sections */
.cv-section {
  margin-bottom: 48px;
}

.cv-section h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  color: #1a1a1a;
}

.cv-entry {
  margin-bottom: 20px;
}

.cv-entry h3 {
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.cv-location {
  font-weight: 300;
  color: rgba(0, 0, 0, 0.35);
}

.cv-section ul {
  list-style: none;
  padding: 0;
}

.cv-section li {
  font-size: 14px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.55);
  font-weight: 300;
  padding: 3px 0;
}

.cv-section li strong {
  font-weight: 500;
  color: rgba(0, 0, 0, 0.7);
}

/* About page responsive: tablet */
@media (max-width: 1024px) {
  .about {
    padding: 32px 24px 60px;
  }

  .about-intro {
    gap: 32px;
  }

  .about-portrait {
    flex: 0 0 200px;
  }
}

/* About page responsive: mobile */
@media (max-width: 600px) {
  .about {
    padding: 24px 16px 40px;
  }

  .about-intro {
    flex-direction: column;
    gap: 24px;
  }

  .about-portrait {
    flex: none;
    max-width: 200px;
  }

  .about-bio h1 {
    font-size: 28px;
  }
}
