/* ==========================================================================
   1. Atmospheric Colors & Variables
   ========================================================================== */
:root {
  --bg-canvas: #F7F6F2;         /* Warm watercolor/limestone paper tone */
  --surface-white: #FFFFFF;     /* Pure white for image framing */
  --text-main: #1A1A1A;         /* Charcoal black */
  --text-subtle: #777775;       /* Muted architectural gray */
  --border-soft: #E8E8E4;
  --border-bold: #D0D0CC;       /* Grounding line separator */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.5;
  padding: 0 5vw;
  position: relative;
}

/* ==========================================================================
   2. Stretched Paper Texture Canvas
   ========================================================================== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-image: url("../images/paper-texture.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover; /* Stretches and scales the sheet seamlessly */
  opacity: 0.20; /* Keeps the organic grain visible without washing out text */
  pointer-events: none;
  z-index: 1;
}

.page-fade {
  animation: gentleFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ==========================================================================
   3. Header & Navigation
   ========================================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 2.2rem 0 1rem 0;
  border-bottom: 2px solid var(--border-bold);
  position: relative;
  z-index: 2;
}

.logo {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.1em;
  line-height: 1;
}

.logo {
  text-decoration: none;
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: opacity 0.2s ease;
}

.logo:hover {
  opacity: 0.7; /* Gives a subtle visual cue that it's clickable */
}

.nav {
  line-height: 1;
}

.nav a {
  margin-left: 2rem;
  color: var(--text-subtle);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  transition: color 0.3s ease;
}

.nav a:hover,
.nav a.active {
  color: var(--text-main);
}

/* ==========================================================================
   4. Layout & Viewport Rules
   ========================================================================== */

/* Standard Pages (Enables vertical scrolling for detail pages) */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.5;
  padding: 0 5vw;
  position: relative;
  min-height: 100vh;
  overflow-y: auto; /* Allows natural scrolling down long detail pages */
}

/* Frontpage Viewport (ONLY applies when body has .fullscreen-body) */
html.fullscreen-html, 
body.fullscreen-body {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden; /* Keeps index.html locked to 1 screen */
  display: flex;
  flex-direction: column;
}

.showcase-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
  position: relative;
  z-index: 2;
}

/* Central container binding Frame, Top Caption, and Bottom Arrows together */
.showcase-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Caption bar sitting directly on top of the image frame */
.caption-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 0.4rem;
  padding: 0 2px;
}

.caption-text {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-subtle);
  font-weight: 500;
}

/* Image Stage Frame */
.stage-container {
  width: 100%;
  display: block;
  text-decoration: none;
  position: relative;
}

.stage-frame {
  width: 100%;
  height: 68vh;
  position: relative;
  background-color: var(--surface-white);
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.stage-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.click-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(247, 246, 242, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.click-overlay span {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background-color: var(--text-main);
  color: #FFFFFF;
  padding: 0.6rem 1.4rem;
}

.stage-container:hover .click-overlay {
  opacity: 1;
}

/* Controls Bar snapped directly below the viewer bottom */
.controls-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.4rem;
}

.control-group {
  display: flex;
  gap: 0.35rem;
}

.nav-arrow-btn {
  background: var(--surface-white);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-arrow-btn:hover {
  border-color: var(--border-bold);
  background-color: #FFFFFF;
}

.fade-in {
  opacity: 1;
  transition: opacity 0.3s ease-in;
}

.fade-out {
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

/* ==========================================================================
   5. Detail Pages Styles
   ========================================================================== */
.container.project-detail {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.back-link {
  font-size: 0.85rem;
  color: var(--text-subtle);
  text-decoration: none;
  transition: color 0.3s ease;
}

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

.project-header {
  padding: 4rem 0 2rem 0;
}

.project-header h1 {
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  background-color: rgba(247, 246, 242, 0.8);
}

.spec-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-subtle);
  margin-bottom: 0.25rem;
}

.spec-value {
  font-size: 0.95rem;
  font-weight: 500;
}

.detail-hero-img {
  margin: 2.5rem 0 4rem 0;
  border: 1px solid var(--border-soft);
  background-color: var(--surface-white);
}

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

.hero-aspect {
  aspect-ratio: 16 / 9;
}

.gallery-aspect {
  aspect-ratio: 4 / 3;
}

.full-aspect {
  aspect-ratio: 16 / 9;
  margin-top: 2rem;
}

.project-narrative {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 4rem;
  margin-bottom: 4rem;
}

.narrative-label h2 {
  font-size: 1.25rem;
  font-weight: 400;
}

.narrative-body p {
  color: #444442;
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.narrative-body p.lead {
  font-size: 1.3rem;
  font-weight: 300;
  color: var(--text-main);
  line-height: 1.5;
}

.gallery-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.next-project {
  margin: 5rem 0 4rem 0;
  padding-top: 3rem;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}

.next-title {
  font-size: 1.6rem;
  font-weight: 300;
  text-decoration: none;
  color: var(--text-main);
  display: inline-block;
  margin-top: 0.5rem;
  transition: transform 0.3s ease;
}

.next-title:hover {
  transform: translateX(6px);
}

@media (max-width: 768px) {
  .project-narrative {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .gallery-row {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Project Archive Page Layout & Filters
   ========================================================================== */
.archive-container {
  max-width: 1400px;
  margin: 0 auto;
  padding-top: 2rem;
  padding-bottom: 5rem;
  position: relative;
  z-index: 2;
}

/* Filter Bar Styling */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.filter-group, .sort-group {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.filter-btn, .sort-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0;
  transition: color 0.25s ease;
}

.filter-btn:hover, .filter-btn.active, .sort-btn:hover {
  color: var(--text-main);
}

.filter-btn.active {
  font-weight: 600;
  border-bottom: 1px solid var(--text-main);
  padding-bottom: 2px;
}

.sort-label {
  font-size: 0.82rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Responsive Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns on desktop */
  gap: 3rem 2.5rem;
}

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

.card-image-frame {
  width: 100%;
  aspect-ratio: 16 / 10;
  background-color: var(--surface-white);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  margin-bottom: 0.8rem;
  transition: border-color 0.3s ease;
}

.card-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
}

.project-card:hover .card-image-frame {
  border-color: var(--border-bold);
}

.project-card:hover .card-image-frame img {
  transform: scale(1.02);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.card-title-row h3 {
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.card-year {
  font-size: 0.85rem;
  color: var(--text-subtle);
}

.card-meta {
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin-top: 0.2rem;
}

@media (max-width: 768px) {
  .projects-grid {
    grid-template-columns: 1fr; /* Single column on mobile */
  }

  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}