/**
 * Layout Styles
 * 
 * Illustration positioned bottom-left. Text columns aligned to top of illustration,
 * with 40px offset from gridlines. Implements the print-inspired, framed page aesthetic.
 */

/* Page Frame - Dark green border wrapper */
.page-frame {
  --line-1: 25%;
  --line-2: 50%;
  --line-3: 75%;
  position: relative;
  min-height: 100vh;
  border: var(--border-width) solid var(--color-border);
  background-color: var(--color-bg-page);
  /* Lines 2 and 3: positions animatable for page transition; line 1 is in ::before so it can fade */
  background-image: 
    linear-gradient(to right, var(--color-gridline) 1px, transparent 1px),
    linear-gradient(to right, var(--color-gridline) 1px, transparent 1px);
  background-position: var(--line-2) 0, var(--line-3) 0;
  background-size: 1px 100%;
  background-repeat: no-repeat;
  padding: var(--content-padding);
}

/* First gridline in its own layer so it can fade out during transition (no movement) */
.page-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, var(--color-gridline) 1px, transparent 1px);
  background-position: var(--line-1) 0;
  background-size: 1px 100%;
  background-repeat: no-repeat;
  /* opacity transition overridden in page-transition.css when .page-transition-out */
  transition: opacity 0.2s ease;
}

/* Page Content - Contains title/logo; above illustration when window is short */
.page-content {
  position: relative;
  z-index: 2;
}

/* Display Name - positioned 16px from top of page */
.display-name {
  font-family: var(--font-display);
  font-size: 128px;
  line-height: 60%;
  color: var(--color-text);
  text-transform: lowercase;
  margin: 0;
  margin-top: 16px;
  font-weight: normal;
  letter-spacing: 0;
}

/* Text columns container - positioned to align with top of illustration */
.text-columns {
  position: absolute;
  top: 50vh; /* Fallback: middle of viewport, will be overridden by JavaScript */
  left: 0;
  right: 0;
  width: 100%;
  z-index: 2; /* Above illustration */
  /* Top position will be set by JavaScript to align with illustration top */
}

/* Text columns: positioned 40px to the right of gridlines */
.column {
  max-width: 192px;
  position: absolute;
  top: 0;
  white-space: normal;
}

.column-bio {
  /* Gridline at 25% of page-frame width, text starts at 25% + 48px */
  left: calc(25% + 48px);
  width: auto;
}

.column-writing {
  /* Gridline at 50% of page-frame width, text starts at 50% + 48px */
  left: calc(50% + 48px);
  width: auto;
}

.column-soon {
  /* Gridline at 75% of page-frame width, text starts at 75% + 48px */
  left: calc(75% + 48px);
  width: auto;
}

.column p {
  margin: 0 0 var(--spacing-sm) 0;
}

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

/* Illustration - absolutely positioned at bottom-left of page */
/* Fixed box (static image aspect 530×1480) so video hover doesn’t resize */
.illustration {
  position: absolute;
  bottom: var(--content-padding);
  left: var(--content-padding);
  z-index: 0;
  width: 172px;
  aspect-ratio: 530 / 1480;
  border: 1px solid var(--color-gridline);
  /* Blend target: the video's white background multiplies against this to
     become exactly the page color (multiply can only darken, never lighten) */
  background: var(--color-bg-page);
}

/* Fill container so image and video share same dimensions */
.illustration img,
.illustration video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.illustration video {
  cursor: pointer;
  /* White video background multiplies down to the box's page-color background,
     guaranteeing the illustration never shows a background lighter than the page */
  mix-blend-mode: multiply;
}

/* Align text columns to top of illustration */
/* We need to calculate where the illustration top is and position text there */
/* Using JavaScript would be ideal, but we can approximate with CSS */
/* For now, we'll position text columns relative to a reference point */
/* The illustration height varies, so we'll need to adjust this */

/* Mobile grid field - hidden on desktop */
.grid-field {
  display: none;
}

/* Responsive: mobile layout with CSS Grid system */
@media (max-width: 768px) {
  .page-frame {
    /* Border reduces from 40px to 24px on all sides */
    border-width: 24px;
    background-color: var(--color-bg-page);
    padding: 0;
    min-height: 100vh;
    position: relative;
    /* Remove desktop gridlines - grid system handles alignment */
    background-image: none;
  }
  
  /* Hide desktop layout elements on mobile */
  .page-content,
  .text-columns,
  .illustration {
    display: none;
  }
  
  /* Show and configure grid field */
  .grid-field {
    display: grid;
    /* 3 vertical zones defined by gridlines:
       Column line 1 = left margin edge
       Column line 2 = LEFT GRIDLINE (40px from left)
       Column line 3 = CENTER GRIDLINE (middle of two 1fr columns)
       Column line 4 = RIGHT GRIDLINE (40px from right)
       Column line 5 = right margin edge */
    grid-template-columns:
      40px          /* left margin to first gridline */
      1fr           /* column A (left gridline to center) */
      1fr           /* column B (center to right gridline) */
      40px;         /* right margin */
    
    row-gap: var(--spacing-lg); /* 64px */
    padding: 0; /* critical: grid + gridlines must start at same edge */
    padding-top: 40px;
    padding-bottom: 64px;
    min-height: calc(100vh - 48px); /* Account for 24px border on each side */
    position: relative;
    
    /* Visual gridlines for alignment rails */
    background-image: 
      linear-gradient(to right, var(--color-gridline) 1px, transparent 1px),
      linear-gradient(to right, var(--color-gridline) 1px, transparent 1px),
      linear-gradient(to right, var(--color-gridline) 1px, transparent 1px);
    background-position: 
      40px 0,              /* Left gridline: 40px from left edge */
      50% 0,               /* Center gridline: 50% width */
      calc(100% - 40px) 0; /* Right gridline: 40px from right edge */
    background-size: 1px 100%;
    background-repeat: no-repeat;
  }
  
  /* Logo - spans from left gridline to center gridline */
  .logo {
    grid-column: 2 / 3;
  }
  
  .logo .logo-svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
  }
  
  /* Intro text - spans from left gridline to center gridline */
  .intro-text {
    grid-column: 2 / 3;
  }
  
  .intro-text p {
    margin: 0 0 var(--spacing-sm) 0;
    white-space: normal;
  }
  
  .intro-text p:last-child {
    margin-bottom: 0;
  }
  
  /* Illustration - spans from left gridline to right gridline */
  .illustration-mobile {
    grid-column: 2 / 4;
  }
  
  .illustration-mobile img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--color-gridline);
  }
  
  /* Lower text - spans from left gridline to center gridline */
  .lower-text {
    grid-column: 2 / 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 16px;
    height: fit-content;
  }
  
  .lower-text p {
    margin: 0 0 var(--spacing-sm) 0;
  }
  
  .lower-text p:last-child {
    margin-bottom: 0;
  }
}

/* Smaller mobile: tighter spacing */
@media (max-width: 480px) {
  .page-frame {
    border-width: 24px;
  }
}
