/* ============================================
   Bill Bain Personal Website
   Art Deco-Inspired Design System
   ============================================ */

/* --- Custom Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Art Deco Palette */
  --cream:        #F5F0E8;
  --cream-light:  #FAF8F3;
  --cream-dark:   #E8E0D0;
  --teal:         #1A5C5A;
  --teal-dark:    #0E3D3B;
  --teal-light:   #2A7A77;
  --gold:         #C4943A;
  --gold-light:   #D4AA54;
  --gold-dark:    #A67A2A;
  --charcoal:     #2C2C2C;
  --charcoal-light: #4A4A4A;
  --white:        #FFFFFF;

  /* Typography */
  --font-serif:   'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --section-padding: clamp(3rem, 8vw, 7rem);

  /* Transitions */
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base Reset & Defaults --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--charcoal);
  background-color: var(--cream-light);
  line-height: 1.7;
  font-size: 1rem;
  overflow-x: hidden;
}

/* --- Art Deco Decorative Elements --- */
.deco-line {
  display: block;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
  margin: 1rem auto;
  border-radius: 2px;
}

.deco-line-left {
  margin-left: 0;
}

.deco-diamond {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.deco-diamond::before,
.deco-diamond::after {
  content: '';
  width: 30px;
  height: 1px;
  background: var(--gold);
}

.deco-diamond span {
  width: 8px;
  height: 8px;
  background: var(--gold);
  transform: rotate(45deg);
  display: block;
  flex-shrink: 0;
}

/* Stepped Art Deco border pattern */
.deco-border-top {
  position: relative;
}

.deco-border-top::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 800px);
  height: 4px;
  background:
    linear-gradient(90deg,
      transparent 0%,
      var(--gold) 10%,
      var(--gold) 20%,
      transparent 20%,
      transparent 25%,
      var(--gold) 25%,
      var(--gold) 75%,
      transparent 75%,
      transparent 80%,
      var(--gold) 80%,
      var(--gold) 90%,
      transparent 100%
    );
}

/* Art Deco corner accents */
.deco-corner {
  position: relative;
}

.deco-corner::before,
.deco-corner::after {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.5;
}

.deco-corner::before {
  top: -8px;
  left: -8px;
  border-width: 2px 0 0 2px;
}

.deco-corner::after {
  bottom: -8px;
  right: -8px;
  border-width: 0 2px 2px 0;
}

/* Geometric fan pattern (SVG background) */
.deco-fan-bg {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0 L60 30 L30 60 L0 30Z' fill='none' stroke='%23C4943A' stroke-width='0.5' opacity='0.08'/%3E%3C/svg%3E");
}

/* Stepped/zigzag divider */
.deco-divider {
  width: 100%;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='20' viewBox='0 0 40 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 20 L10 0 L20 20 L30 0 L40 20' fill='none' stroke='%23C4943A' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
}

/* --- Section Headings --- */
.section-heading {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.section-subheading {
  font-family: var(--font-sans);
  font-weight: 300;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--gold);
}

/* --- Hero Section --- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-dark);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40Z' fill='none' stroke='%23C4943A' stroke-width='0.5' opacity='0.12'/%3E%3Ccircle cx='40' cy='40' r='15' fill='none' stroke='%23C4943A' stroke-width='0.3' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none;
}

.hero::after {
  display: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 6rem 2rem;
}

@media (min-width: 640px) {
  .hero-content {
    padding: 7rem 2rem;
  }
}

@media (min-width: 1024px) {
  .hero-content {
    padding: 8rem 2rem;
  }
}

/* Split hero frame layout */
.hero-frame-split {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .hero-frame-split {
    flex-direction: row;
    align-items: center;
    gap: 5rem;
  }
}

.hero-text {
  flex: 1;
  min-width: 0;
}

/* Hero photo inside the frame */
.hero-photo {
  flex-shrink: 0;
  width: 240px;
  max-width: 100%;
}

@media (min-width: 640px) {
  .hero-photo {
    width: 260px;
  }
}

@media (min-width: 1024px) {
  .hero-photo {
    width: 280px;
  }
}

@media (min-width: 1280px) {
  .hero-photo {
    width: 320px;
  }
}

/* Hero photo frame with gold border + geometric corner details */
.hero-photo-frame {
  position: relative;
  padding: 5px;
  border: 2px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  transform: rotate(3deg);
}

/* Geometric corner accents — stepped Art Deco corners */
.hero-photo-frame::before,
.hero-photo-frame::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--gold-light);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
}

.hero-photo-frame::before {
  top: -6px;
  left: -6px;
  border-width: 2px 0 0 2px;
}

.hero-photo-frame::after {
  bottom: -6px;
  right: -6px;
  border-width: 0 2px 2px 0;
}

/* Additional corners via child pseudo-elements on the inner wrapper */
.hero-photo-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.hero-photo-corners::before,
.hero-photo-corners::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--gold-light);
  border-style: solid;
}

.hero-photo-corners::before {
  top: -6px;
  right: -6px;
  border-width: 2px 2px 0 0;
}

.hero-photo-corners::after {
  bottom: -6px;
  left: -6px;
  border-width: 0 0 2px 2px;
}

.hero-photo-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* Stepped Art Deco frame around hero content */
.hero-frame {
  position: relative;
  padding: 3rem 2.5rem;
}

.hero-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(196, 148, 58, 0.3);
  pointer-events: none;
}

.hero-frame::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(196, 148, 58, 0.15);
  pointer-events: none;
}

@media (min-width: 640px) {
  .hero-frame {
    padding: 4rem 3.5rem;
  }
}

/* --- Navigation --- */
.nav-sticky {
  transition: background-color var(--transition-smooth),
              box-shadow var(--transition-smooth),
              backdrop-filter var(--transition-smooth);
}

.nav-sticky.scrolled {
  background-color: rgba(245, 240, 232, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

.nav-link {
  position: relative;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charcoal);
  text-decoration: none;
  padding: 0.5rem 0;
  transition: color var(--transition-smooth);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gold);
  transition: width var(--transition-smooth);
}

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

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* --- Photo Gallery --- */
.masonry-grid {
  columns: 1;
  column-gap: 1rem;
}

@media (min-width: 640px) {
  .masonry-grid {
    columns: 2;
  }
}

@media (min-width: 1024px) {
  .masonry-grid {
    columns: 3;
  }
}

@media (min-width: 1280px) {
  .masonry-grid {
    columns: 4;
  }
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 1rem;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.masonry-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.masonry-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s ease;
}

.masonry-item:hover img {
  transform: scale(1.03);
}

.masonry-item .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(14, 61, 59, 0.85) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-smooth);
  display: flex;
  align-items: flex-end;
  padding: 1.25rem;
}

.masonry-item:hover .overlay {
  opacity: 1;
}

.overlay-text {
  color: var(--white);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.4;
}

.overlay-year {
  color: var(--gold-light);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* Gallery filter buttons */
.filter-btn {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--cream-dark);
  border-radius: 2px;
  background: transparent;
  color: var(--charcoal-light);
  cursor: pointer;
  transition: all var(--transition-smooth);
}

.filter-btn:hover {
  border-color: var(--gold);
  color: var(--teal);
}

.filter-btn.active {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
}

/* --- Lightbox --- */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 14, 0.95);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: var(--cream);
  max-width: 600px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  transition: all var(--transition-smooth);
  font-size: 1.25rem;
}

.lightbox-nav:hover {
  background: rgba(196, 148, 58, 0.3);
  border-color: var(--gold);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  transition: all var(--transition-smooth);
  font-size: 1.25rem;
}

.lightbox-close:hover {
  background: rgba(196, 148, 58, 0.3);
  border-color: var(--gold);
}

/* --- Memoir Section --- */
.memoir-nav {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
}

.memoir-nav::-webkit-scrollbar {
  width: 3px;
}

.memoir-nav::-webkit-scrollbar-track {
  background: transparent;
}

.memoir-nav::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 3px;
}

.chapter-link {
  display: block;
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--charcoal-light);
  text-decoration: none;
  border-left: 2px solid var(--cream-dark);
  transition: all var(--transition-smooth);
  line-height: 1.4;
}

.chapter-link:hover,
.chapter-link.active {
  color: var(--teal);
  border-left-color: var(--gold);
  background: rgba(196, 148, 58, 0.05);
}

.chapter-link.active {
  font-weight: 500;
}

/* Memoir prose styling */
.memoir-prose {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--charcoal);
}

.memoir-prose h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  color: var(--teal-dark);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--cream-dark);
}

.memoir-prose h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.memoir-prose p {
  margin-bottom: 1.25rem;
}

.memoir-prose .drop-cap::first-letter {
  font-family: var(--font-serif);
  font-size: 3.5em;
  float: left;
  line-height: 0.8;
  margin-right: 0.1em;
  margin-top: 0.1em;
  color: var(--teal);
}

.memoir-prose blockquote {
  border-left: 3px solid var(--gold);
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background: rgba(196, 148, 58, 0.05);
  font-style: italic;
  color: var(--charcoal-light);
}

.memoir-prose .photo-inline {
  margin: 2rem 0;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: none;
}

.memoir-prose .photo-inline img {
  width: 100%;
  height: auto;
  display: block;
}

.memoir-prose .photo-inline figcaption {
  padding: 0.75rem 1rem;
  background: transparent;
  font-size: 0.85rem;
  color: var(--charcoal-light);
  font-style: italic;
  text-align: center;
}

.memoir-prose .photo-inline.photo-portrait {
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.memoir-prose .photo-inline.photo-portrait-mini {
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}

/* Float photos on larger screens */
@media (min-width: 768px) {
  .memoir-prose .photo-float-right {
    float: right;
    width: 45%;
    margin: 0.5rem 0 1.5rem 2rem;
  }

  .memoir-prose .photo-float-left {
    float: left;
    width: 45%;
    margin: 0.5rem 2rem 1.5rem 0;
  }
}

/* --- About Section --- */

/* Photo frame matching the hero treatment */
.about-photo-frame {
  position: relative;
  padding: 5px;
  border: 2px solid var(--gold);
  border-radius: 2px;
  background: var(--white);
}

/* Corner accents — top-left & bottom-right */
.about-photo-frame::before,
.about-photo-frame::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--gold-light);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
}

.about-photo-frame::before {
  top: -6px;
  left: -6px;
  border-width: 2px 0 0 2px;
}

.about-photo-frame::after {
  bottom: -6px;
  right: -6px;
  border-width: 0 2px 2px 0;
}

/* Corner accents — top-right & bottom-left */
.about-photo-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.about-photo-corners::before,
.about-photo-corners::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--gold-light);
  border-style: solid;
}

.about-photo-corners::before {
  top: -6px;
  right: -6px;
  border-width: 2px 2px 0 0;
}

.about-photo-corners::after {
  bottom: -6px;
  left: -6px;
  border-width: 0 0 2px 2px;
}

/* --- Footer --- */
.footer {
  background: var(--teal-dark);
  color: rgba(245, 240, 232, 0.8);
}

.footer a {
  color: var(--gold-light);
  text-decoration: none;
  transition: color var(--transition-smooth);
}

.footer a:hover {
  color: var(--gold);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease forwards;
}

.animate-fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.animate-scale-in {
  animation: scaleIn 0.5s ease forwards;
}

/* Scroll-triggered animation classes (controlled by Alpine) */
[x-intersect] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.revealed {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Stagger children animation */
.stagger-children > * {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.revealed > *:nth-child(1) { transition-delay: 0.05s; }
.stagger-children.revealed > *:nth-child(2) { transition-delay: 0.1s; }
.stagger-children.revealed > *:nth-child(3) { transition-delay: 0.15s; }
.stagger-children.revealed > *:nth-child(4) { transition-delay: 0.2s; }
.stagger-children.revealed > *:nth-child(5) { transition-delay: 0.25s; }
.stagger-children.revealed > *:nth-child(6) { transition-delay: 0.3s; }
.stagger-children.revealed > *:nth-child(7) { transition-delay: 0.35s; }
.stagger-children.revealed > *:nth-child(8) { transition-delay: 0.4s; }

.stagger-children.revealed > * {
  opacity: 1;
  transform: translateY(0);
}

/* --- Utility --- */
.text-balance {
  text-wrap: balance;
}

/* Smooth image placeholder */
.img-placeholder {
  background: linear-gradient(135deg, var(--cream-dark) 0%, var(--cream) 100%);
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--cream);
}

::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dark);
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--teal);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 4px 4px;
  z-index: 10000;
  font-weight: 500;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Print styles */
@media print {
  .nav-sticky,
  .lightbox-backdrop,
  .filter-btn {
    display: none !important;
  }

  .hero {
    min-height: auto;
    padding: 2rem;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
}
