/* ==========================================================================
   Joshua Jones Lofflin — Author Website
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens & CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Typography */
  --font-nav: "League Spartan", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Cardo", Georgia, serif;

  /* Colors */
  --color-bg: #ffffff;
  --color-bg-hero: #EBEBE9; /*#F4F6F2; /* Full-width background behind headshot */
  --color-text-main: #484646;
  --color-text-body: #1e1e1e;
  --color-text-muted: #484646;
  --color-text-subtle: #757575;
  --color-border-subtle: #e2dfda;
  --color-border-focus: #1a1a1a;

  /* Exact Desktop Metrics */
  --canvas-max-width: 1040px;
  --photo-width: 438px;
  --photo-height: 400px;
  --bio-width: 382px;
  --column-gap: 36px;
  --text-hang-left: -21px;
  --hero-top-margin: 36px;
  --mobile-top-margin: 9px;
  --mobile-side-padding: 32px;
}

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

html {
  font-size: 16px;
  background-color: var(--color-bg);
  color: var(--color-text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Prevent ANY horizontal shift when content height changes */
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  overflow-x: hidden;
  line-height: 1.5;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 16px;
  padding: 8px 16px;
  background: #000;
  color: #fff;
  font-family: var(--font-nav);
  font-size: 0.875rem;
  z-index: 1000;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 16px;
}

/* --------------------------------------------------------------------------
   Hero Band: Full-width Rectangular Background (#D2DBCB)
   Matches the vertical dimensions of the headshot image
   -------------------------------------------------------------------------- */
.hero-band {
  width: 100%;
  background-color: var(--color-bg-hero);
  margin-top: var(--hero-top-margin);
  display: flex;
  justify-content: center;
}

/* Gradient extending from hero band's lower bound (#F4F6F2) to bottom of screen (white) */
.content-band {
  width: 100%;
  flex: 1;
  background: linear-gradient(to bottom, var(--color-bg-hero) 0%, #ffffff 100%);
  display: flex;
  justify-content: center;
  min-height: calc(100vh - (var(--hero-top-margin) + var(--photo-height)));
}

.hero-canvas {
  padding-top: 0;
  padding-bottom: 0;
  height: var(--photo-height);
}

.site-canvas {
  width: 100%;
  max-width: var(--canvas-max-width);
  margin: 0 auto;
  padding: 0 32px 0 80px;
}

.content-canvas {
  padding-top: 48px;
  padding-bottom: 64px;
}

/* Hidden by default on desktop; enabled on mobile */
.mobile-divider {
  display: none;
}

/* --------------------------------------------------------------------------
   Top Row: Hero Section (Headshot + Bio)
   -------------------------------------------------------------------------- */
.hero-section {
  display: grid;
  grid-template-columns: var(--photo-width) var(--bio-width);
  column-gap: var(--column-gap);
  align-items: center;
  position: relative;
  width: fit-content;
  height: var(--photo-height);
}

/* Portrait Stage */
.portrait-stage {
  position: relative;
  width: var(--photo-width);
  height: var(--photo-height);
  flex-shrink: 0;
}

.photo-wrapper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.author-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Overlaid Navigation: Text sits over baked bars, extending to the left */
.ribbon-nav {
  position: absolute;
  top: 0;
  left: var(--text-hang-left);
  width: calc(100% - var(--text-hang-left));
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.nav-item {
  position: absolute;
  left: 0;
  transform: translateY(-50%);
  pointer-events: auto;
  white-space: nowrap;
}

/* Precise vertical centering matching each baked bar in headshot.png */
.nav-item-brand {
  top: 20.00%;
}

.nav-item-work {
  top: 42.88%;
}

.nav-item-awards {
  top: 64.75%;
}

.nav-item-contact {
  top: 84.75%;
}

.nav-item-handle {
  top: 97.75%;
}

/* Navigation Links (Transparent background, no conflicting white bars) */
.brand-heading {
  font-size: 1em;
  font-weight: 400;
  line-height: 1;
}

/* "JJLofflin": 144 pt mockup scale (72px / 4.5rem on desktop) */
.brand-link {
  font-family: var(--font-nav);
  font-size: clamp(3.25rem, 6.8vw, 4.5rem);
  font-weight: 400;
  color: var(--color-text-main);
  text-decoration: none;
  letter-spacing: -0.025em;
  line-height: 1;
  display: inline-block;
  background: transparent;
  transition: color 0.15s ease;
}

.brand-link:hover {
  color: #593535;
}

/* Navigation links: 96 pt mockup scale (48px / 3rem on desktop) */
.ribbon-link {
  font-family: var(--font-nav);
  font-size: clamp(2.2rem, 4.5vw, 3rem);
  font-weight: 300;
  color: var(--color-text-main);
  text-decoration: none;
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-block;
  background: transparent;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.ribbon-link:hover {
  color: #593535;
}

.ribbon-link:focus-visible {
  outline: 2px solid var(--color-text-main);
  outline-offset: 4px;
}

/* Active Nav Indicator (Preserves exact dimensions - ZERO layout shift) */
.ribbon-link.active {
  text-shadow: 0 0 0.5px rgba(0, 0, 0, 0.4);
}

/* Social Handle */
.handle-button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-nav);
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  font-weight: 400;
  color: var(--color-text-muted);
  letter-spacing: -0.01em;
  line-height: 1;
  display: inline-block;
  padding: 0;
  transition: color 0.15s ease;
}

.handle-button:hover,
.handle-button[aria-expanded="true"] {
  color: #000;
}

.handle-button:focus-visible {
  outline: 2px solid var(--color-text-main);
  outline-offset: 4px;
}

/* Social Dropdown Popover */
.social-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #ffffff;
  border: 1px solid var(--color-border-subtle);
  border-radius: 4px;
  padding: 6px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  min-width: 140px;
  z-index: 50;
  display: none;
  flex-direction: column;
}

.social-dropdown.show {
  display: flex;
}

.social-dropdown a {
  padding: 8px 16px;
  font-family: var(--font-nav);
  font-size: 0.95rem;
  color: var(--color-text-main);
  text-decoration: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.15s ease;
}

.social-dropdown a:hover {
  background-color: #f7f7f7;
  color: #000;
}

.social-dropdown a span {
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

/* --------------------------------------------------------------------------
   Bio Column (Right Side - Pinned in Hero Band)
   -------------------------------------------------------------------------- */
.bio-column {
  width: var(--bio-width);
  max-width: var(--bio-width);
  padding-left: 0;
}

.bio-text {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--color-text-body);
  font-weight: 400;
}

.bio-text em {
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Lower Row: Dynamic Content Stage (Beneath Portrait)
   -------------------------------------------------------------------------- */
.content-stage {
  width: var(--photo-width);
  min-height: 240px;
  margin-left: 0;
  outline: none;
}

/* View Panels Animation & Display */
.view-panel {
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.view-panel.active {
  display: block;
  opacity: 1;
}

/* Literary List Styling (Selected Work & Awards) */
.literary-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.literary-list li {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--color-text-body);
}

.literary-list a {
  color: var(--color-text-body);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.literary-list a:hover {
  color: #000;
  border-bottom-color: var(--color-text-subtle);
}

.literary-list a:focus-visible {
  outline: 2px solid var(--color-text-main);
  outline-offset: 2px;
}

.pub-sep {
  margin: 0 4px;
  color: var(--color-text-subtle);
}

.pub-name {
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Additional Work Drawer (Collapsed by Default)
   -------------------------------------------------------------------------- */
.more-work-container {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--color-border-subtle);
}

.more-work-toggle {
  background: none;
  border: none;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s ease;
}

.more-work-toggle:hover {
  color: #000;
}

.more-work-toggle:focus-visible {
  outline: 2px solid var(--color-text-main);
  outline-offset: 2px;
}

/* Strict hidden state so display:flex never overrides [hidden] */
.more-work-list[hidden] {
  display: none !important;
}

.more-work-list:not([hidden]) {
  display: flex;
  margin-top: 16px;
}

/* --------------------------------------------------------------------------
   Contact Form View
   -------------------------------------------------------------------------- */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.form-group input,
.form-group textarea {
  font-family: var(--font-serif);
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 2px;
  background-color: #faf9f7;
  color: var(--color-text-main);
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  background-color: #ffffff;
  box-shadow: 0 0 0 1px var(--color-border-focus);
}

.form-group textarea {
  resize: vertical;
  min-height: 96px;
}

.form-action {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.submit-btn {
  background-color: var(--color-text-main);
  color: #ffffff;
  font-family: var(--font-nav);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 10px 24px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.submit-btn:hover {
  background-color: #000000;
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:focus-visible {
  outline: 2px solid var(--color-text-main);
  outline-offset: 2px;
}

.form-status {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Responsive Layout (Mobile & Tablet)
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .hero-band {
    height: auto;
    margin-top: var(--mobile-top-margin); /* ~9px white space from top */
  }

  .hero-canvas {
    height: auto;
    padding: 24px var(--mobile-side-padding);
  }

  .site-canvas {
    padding: 0 var(--mobile-side-padding);
  }

  .hero-section {
    grid-template-columns: 1fr;
    row-gap: 32px;
    width: 100%;
    height: auto;
  }

  .portrait-stage {
    width: 100%;
    max-width: 438px;
    height: auto;
    aspect-ratio: 438 / 400;
    margin: 0 auto;
  }

  .bio-column {
    width: 100%;
    max-width: 438px;
    margin: 0 auto;
  }

  .content-band {
    min-height: calc(100vh - 420px);
  }

  .content-canvas {
    padding-top: 40px;
    padding-bottom: 48px;
  }

  /* Decorative mobile divider (+   +   +) */
  .mobile-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    font-family: var(--font-nav);
    font-weight: 200; /* League Spartan Extra Light */
    font-size: clamp(2.2rem, 7vw, 2.625rem); /* 84 pt equivalent */
    color: #484646;
    line-height: 1;
    margin: 20px auto 24px auto;
    user-select: none;
  }

  .content-stage {
    width: 100%;
    max-width: 438px;
    margin: 0 auto;
  }

  /* Hide bio + decorative divider on mobile when a section (non-about) is active */
  body.view-section-active .bio-column {
    display: none;
  }

  body.view-section-active .mobile-divider {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Accessibility: Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
