/* ============================================
   nonri.day — Design Language Stylesheet
   Korean earth pigments, manuscript aesthetics
   ============================================ */

:root {
  --bg-cream: #F4EDE4;
  --text-dark: #3B2F2A;
  --text-secondary: #4A3F38;
  --accent-red: #B8532E;
  --accent-gold: #A69279;
  --text-margin: #8B7D6B;
  --paper-aged: #EDE5D8;
  --shadow-depth: #D4C8B8;
}

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

html {
  scroll-behavior: smooth;
}

/* ---- Body / Paper Grain ---- */
body {
  font-family: 'Source Serif 4', Georgia, serif;
  background-color: var(--bg-cream);
  color: var(--text-secondary);
  line-height: 1.618;
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  font-weight: 400;
  position: relative;
  overflow-x: hidden;
}

/* Paper grain texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* Hidden SVG filter definition */
.paper-grain-filter {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---- Page Layout (Asymmetric) ---- */
.page-wrapper {
  position: relative;
  min-height: 100vh;
}

.content-column {
  width: 60%;
  max-width: 640px;
  margin-left: 10%;
  padding: 0 2rem;
  padding-top: 4rem;
  padding-bottom: 8rem;
  position: relative;
  z-index: 2;
}

/* ---- Right Margin Area ---- */
.right-margin {
  position: fixed;
  top: 0;
  right: 0;
  width: 40%;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

/* ---- Coffee Ring Motif ---- */
.coffee-ring {
  position: absolute;
  border-radius: 45% 55% 60% 40% / 50% 60% 30% 70%;
  background: radial-gradient(
    ellipse at 35% 35%,
    transparent 50%,
    var(--accent-gold) 52%,
    var(--accent-gold) 56%,
    transparent 58%
  );
  opacity: 0.06;
  pointer-events: none;
}

/* ---- Wordmark ---- */
.wordmark {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.75rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold);
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.wordmark.visible {
  opacity: 1;
}

/* ---- Notebook Entries ---- */
.notebook-entry {
  margin-bottom: 6rem;
  position: relative;
  will-change: filter, opacity;
  transition: filter 0.6s cubic-bezier(0.25, 0.1, 0.25, 1),
              opacity 0.6s ease;
}

.notebook-entry:first-of-type {
  margin-top: 0;
}

/* ---- Entry Labels (Date-like markers) ---- */
.entry-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold);
  display: block;
  margin-bottom: 0.75rem;
}

/* ---- Entry Headings ---- */
.entry-heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  line-height: 1.2;
  color: var(--accent-gold);
  letter-spacing: 0.3em;
  margin-bottom: 1.5rem;
  transition: letter-spacing 0.8s cubic-bezier(0.25, 0.1, 0.25, 1),
              color 0.8s ease;
  /* Ink bleed effect */
  text-shadow:
    0.5px 0 0 rgba(59, 47, 42, 0.2),
    -0.5px 0 0 rgba(59, 47, 42, 0.2),
    0 0.5px 0 rgba(59, 47, 42, 0.2),
    0 -0.5px 0 rgba(59, 47, 42, 0.2);
}

/* Heading in focused state: letters gather, color darkens */
.notebook-entry.focused .entry-heading {
  letter-spacing: -0.02em;
  color: var(--text-dark);
}

/* ---- Body Text ---- */
.entry-body p {
  margin-bottom: 1.5rem;
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.618;
  color: var(--text-secondary);
  font-weight: 400;
}

.entry-body p em {
  font-style: italic;
  font-weight: 600;
  color: var(--text-dark);
}

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

/* ---- Margin Notes ---- */
.margin-note {
  position: absolute;
  right: -55%;
  top: 2rem;
  width: 200px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.03em;
  color: var(--text-margin);
}

.margin-teaser {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.margin-full {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
              opacity 0.4s ease;
}

/* When parent entry is focused, reveal full margin note */
.notebook-entry.focused .margin-teaser {
  display: none;
}

.notebook-entry.focused .margin-full {
  max-height: 300px;
  opacity: 1;
}

/* ---- Section Separators ---- */
.section-separator {
  text-align: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300;
  font-size: 1rem;
  color: var(--accent-gold);
  letter-spacing: 0.5em;
  margin: 2rem 0;
  padding: 2rem 0;
}

/* ---- Mixed-Media Images ---- */
.mixed-media {
  position: relative;
  width: 100%;
  height: 280px;
  margin: 2rem 0;
  overflow: hidden;
}

.media-photo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.photo-placeholder {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  /* Desaturated, overexposed look */
  filter: saturate(0.3) brightness(1.1) contrast(0.9);
}

/* Texture overlays for photo placeholders */
.photo-texture,
.photo-texture-bark,
.photo-texture-stone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.photo-texture {
  background:
    radial-gradient(ellipse at 30% 40%, rgba(164, 146, 121, 0.3) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 60%, rgba(212, 200, 184, 0.4) 0%, transparent 50%),
    linear-gradient(135deg, rgba(75, 63, 56, 0.08) 0%, transparent 50%);
}

.photo-texture-bark {
  background:
    repeating-linear-gradient(
      2deg,
      transparent 0px,
      transparent 3px,
      rgba(75, 63, 56, 0.06) 3px,
      rgba(75, 63, 56, 0.06) 4px
    ),
    radial-gradient(ellipse at 50% 50%, rgba(166, 146, 121, 0.2) 0%, transparent 70%);
}

.photo-texture-stone {
  background:
    radial-gradient(circle at 25% 25%, rgba(139, 125, 107, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 75% 75%, rgba(184, 83, 46, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(212, 200, 184, 0.3) 0%, transparent 60%);
}

/* SVG Annotation Overlay */
.annotation-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.annotation-path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 1.2s ease-in-out;
}

.annotation-text {
  opacity: 0;
  transition: opacity 0.8s ease 0.6s;
}

/* Animate paths when parent entry is focused */
.notebook-entry.focused .annotation-path {
  stroke-dashoffset: 0;
}

.notebook-entry.focused .annotation-text {
  opacity: 1;
}

/* ---- Blur States ---- */
.notebook-entry.blur-near {
  filter: blur(1.5px);
  opacity: 0.85;
}

.notebook-entry.blur-mid {
  filter: blur(3px);
  opacity: 0.75;
}

.notebook-entry.blur-far {
  filter: blur(5px);
  opacity: 0.7;
}

.notebook-entry.focused {
  filter: none;
  opacity: 1;
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1024px) {
  .content-column {
    width: 65%;
    margin-left: 5%;
  }

  .margin-note {
    right: -50%;
    width: 180px;
  }

  .right-margin {
    width: 35%;
  }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 768px) {
  .content-column {
    width: 90%;
    margin: 0 auto;
    padding: 3rem 1.5rem 6rem;
  }

  .right-margin {
    display: none;
  }

  /* Margin notes become inline accordions on mobile */
  .margin-note {
    position: relative;
    right: auto;
    top: auto;
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--paper-aged);
    border-left: 2px solid var(--accent-gold);
    cursor: pointer;
  }

  .margin-teaser {
    white-space: normal;
  }

  .margin-full {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.4s ease;
  }

  /* On mobile, focused state does NOT auto-expand margin notes */
  .notebook-entry.focused .margin-teaser {
    display: block;
  }

  .notebook-entry.focused .margin-full {
    max-height: 0;
    opacity: 0;
  }

  /* Tapped/expanded state for mobile */
  .margin-note.expanded .margin-teaser {
    display: none;
  }

  .margin-note.expanded .margin-full {
    max-height: 300px;
    opacity: 1;
  }

  .notebook-entry {
    margin-bottom: 4rem;
  }

  .coffee-ring {
    display: none;
  }
}

@media (max-width: 480px) {
  .content-column {
    padding: 2rem 1rem 5rem;
  }

  .entry-heading {
    font-size: 1.5rem;
  }

  .mixed-media {
    height: 200px;
  }
}
