/* ============================================
   eesugi.com - Styles
   A 1970s Japanese kissaten food magazine
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-parchment: #F5E6D0;
  --color-deep-parchment: #EDE0CC;
  --color-linen: #E8D5BA;
  --color-coffee: #3B2314;
  --color-walnut: #4A3728;
  --color-umber: #8B7355;
  --color-saddle: #8B4513;
  --color-terracotta: #C4652A;
  --color-copper: #6B8F71;
  --color-brass: #C4A882;
  --color-tan: #D2B48C;
  --color-charred: #2C1810;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Lora', 'Times New Roman', serif;
  --font-caption: 'Cormorant Garamond', Garamond, serif;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  scroll-behavior: smooth;
  overflow: hidden;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--color-walnut);
  background: var(--color-parchment);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Washi Paper Grain Texture (on body) --- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  opacity: 0.4;
}

/* --- Magazine Scroll Container --- */
.magazine {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

/* --- Spread (each section = full viewport) --- */
.spread {
  height: 100vh;
  width: 100%;
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
}

.spread-inner {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
}

/* --- Spine Ornament (vertical center line with diamonds) --- */
.spine-ornament {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  background: rgba(139, 115, 85, 0.3);
}

/* Diamond shapes along the spine */
.spine-ornament::before {
  content: '';
  position: absolute;
  top: 0;
  left: -2px;
  width: 5px;
  height: 100%;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 8px,
    rgba(196, 168, 130, 0.4) 8px,
    rgba(196, 168, 130, 0.4) 12px,
    transparent 12px,
    transparent 24px
  );
  mask-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 8px,
    black 8px,
    black 12px,
    transparent 12px,
    transparent 24px
  );
  -webkit-mask-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 8px,
    black 8px,
    black 12px,
    transparent 12px,
    transparent 24px
  );
  transform: rotate(45deg);
  transform-origin: center;
}


/* ======================
   SPREAD 1: COVER
   ====================== */
.spread-cover {
  background: var(--color-parchment);
}

.spread-cover .spread-inner {
  position: relative;
}

.cover-image-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.cover-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(15%) saturate(85%) brightness(95%) contrast(105%);
}

.cover-title-block {
  position: absolute;
  top: 8vh;
  left: 6vw;
  z-index: 5;
  background: rgba(245, 230, 208, 0.85);
  padding: 2.5rem 3rem;
}

.cover-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 8vw, 6rem);
  letter-spacing: 0.02em;
  color: var(--color-coffee);
  line-height: 1.1;
}

.cover-subtitle {
  font-family: var(--font-caption);
  font-weight: 300;
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-umber);
  margin-top: 0.5rem;
}

.cover-spine-text {
  position: absolute;
  top: 50%;
  right: 3vw;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.spine-text-item {
  font-family: var(--font-caption);
  font-weight: 300;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-umber);
}

/* Grain overlay for photos */
.grain-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23grain)' opacity='0.03'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 1;
}


/* ======================
   SPREAD 2: FEATURE
   ====================== */
.spread-feature {
  background: var(--color-parchment);
}

.spread-feature .spread-inner {
  display: flex;
  align-items: stretch;
}

.feature-left {
  width: 55%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4vh 3vw 4vh 5vw;
}

.feature-image-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  flex-shrink: 0;
}

.feature-photo {
  width: 100%;
  height: auto;
  display: block;
  filter: sepia(15%) saturate(85%) brightness(95%) contrast(105%);
}

/* Ink bleed feathered edges on photos */
.feature-image-container .feature-photo,
.grid-image-frame svg,
.colophon-photo {
  mask-image: radial-gradient(
    ellipse 95% 95% at center,
    black 85%,
    transparent 100%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 95% 95% at center,
    black 85%,
    transparent 100%
  );
}

.photo-caption {
  font-family: var(--font-caption);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(0.75rem, 0.9vw, 0.875rem);
  letter-spacing: 0.04em;
  color: var(--color-umber);
  margin-top: 1rem;
  text-align: center;
}

.feature-right {
  width: 45%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6vh 5vw 6vh 3vw;
  overflow-y: auto;
}

.spread-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: 0.02em;
  color: var(--color-coffee);
  line-height: 1.15;
  margin-bottom: 2rem;
}

.feature-text p,
.feature-text-continued p {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  line-height: 1.85;
  color: var(--color-walnut);
  margin-bottom: 1.4em;
}

/* Drop Cap */
.drop-cap {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 4.5rem;
  color: var(--color-saddle);
  float: left;
  line-height: 0.8;
  margin-right: 8px;
  margin-top: 0.1em;
  border-bottom: 2px solid var(--color-brass);
  padding-bottom: 2px;
}

/* Pull Quote */
.pull-quote {
  margin: 2rem 0;
  padding: 0;
}

.pull-quote blockquote {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  line-height: 1.5;
  color: var(--color-saddle);
  padding: 1.5rem 0;
  text-align: left;
}

/* Ornamental horizontal rule */
.ornamental-rule {
  height: 1px;
  background: var(--color-brass);
  width: 100%;
}

/* Corner Brackets */
.corner-bracket {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 3;
}

.corner-tl {
  top: -2px;
  left: -2px;
  border-top: 2px solid var(--color-brass);
  border-left: 2px solid var(--color-brass);
}

.corner-tr {
  top: -2px;
  right: -2px;
  border-top: 2px solid var(--color-brass);
  border-right: 2px solid var(--color-brass);
}

.corner-bl {
  bottom: -2px;
  left: -2px;
  border-bottom: 2px solid var(--color-brass);
  border-left: 2px solid var(--color-brass);
}

.corner-br {
  bottom: -2px;
  right: -2px;
  border-bottom: 2px solid var(--color-brass);
  border-right: 2px solid var(--color-brass);
}


/* ======================
   SPREAD 3: GALLERY
   ====================== */
.spread-gallery {
  background: var(--color-parchment);
}

.spread-gallery .spread-inner {
  display: flex;
  align-items: stretch;
}

.gallery-left {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 3vw 4vh 5vw;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 500px;
}

.grid-item {
  display: flex;
  flex-direction: column;
}

.grid-image-frame {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--color-tan);
  overflow: hidden;
}

.grid-image-frame svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: sepia(15%) saturate(85%) brightness(95%) contrast(105%);
}

.grid-caption {
  font-family: var(--font-caption);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(0.7rem, 0.8vw, 0.8rem);
  letter-spacing: 0.04em;
  color: var(--color-umber);
  margin-top: 0.5rem;
  text-align: center;
}

.gallery-right {
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6vh 5vw 6vh 3vw;
}


/* ======================
   SPREAD 4: ESSAY
   ====================== */
.spread-essay {
  background: var(--color-deep-parchment);
}

.spread-essay .spread-inner {
  justify-content: center;
  align-items: center;
  padding: 6vh 5vw;
}

.essay-content {
  display: flex;
  gap: 4vw;
  max-width: 1100px;
  width: 100%;
}

.essay-column {
  flex: 1;
}

.essay-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  letter-spacing: 0.02em;
  color: var(--color-coffee);
  line-height: 1.15;
  margin-bottom: 1.8rem;
}

.essay-column p {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  line-height: 1.85;
  color: var(--color-walnut);
  margin-bottom: 1.4em;
}

/* Essay Divider: line - fleuron - line */
.essay-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.5rem 0;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: var(--color-brass);
}

.fleuron {
  font-family: serif;
  font-size: 1.2rem;
  color: var(--color-brass);
  line-height: 1;
}


/* ======================
   SPREAD 5: COLOPHON
   ====================== */
.spread-colophon {
  background: var(--color-charred);
}

.spread-colophon .spread-inner {
  justify-content: center;
  align-items: center;
}

.colophon-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  max-width: 600px;
  padding: 4vh 3vw;
}

.colophon-image-container {
  width: 100%;
  max-width: 500px;
}

.ornamental-border {
  position: relative;
  padding: 12px;
  border: 1px solid rgba(196, 168, 130, 0.3);
}

.colophon-photo {
  width: 100%;
  height: auto;
  display: block;
  filter: sepia(15%) saturate(85%) brightness(95%) contrast(105%);
}

.colophon-text {
  text-align: center;
}

.colophon-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: 0.02em;
  color: var(--color-parchment);
  margin: 1.5rem 0;
}

.colophon-details {
  margin-bottom: 1.5rem;
}

.colophon-line {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(0.85rem, 1vw, 0.95rem);
  line-height: 2;
  color: var(--color-linen);
}

.colophon-label {
  font-family: var(--font-caption);
  font-weight: 400;
  font-size: clamp(0.7rem, 0.85vw, 0.8rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-umber);
  margin-right: 1em;
}

.colophon-farewell {
  font-family: var(--font-body);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(0.9rem, 1.1vw, 1.05rem);
  line-height: 1.8;
  color: var(--color-brass);
  margin-top: 1rem;
}

/* Colophon dividers */
.spread-colophon .divider-line {
  background: rgba(196, 168, 130, 0.4);
}

.spread-colophon .fleuron {
  color: rgba(196, 168, 130, 0.6);
}

/* Colophon spine ornament on dark background */
.spread-colophon .spine-ornament {
  background: rgba(196, 168, 130, 0.15);
}

.spread-colophon .spine-ornament::before {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 8px,
    rgba(196, 168, 130, 0.25) 8px,
    rgba(196, 168, 130, 0.25) 12px,
    transparent 12px,
    transparent 24px
  );
}


/* ======================
   PAGE INDICATOR
   ====================== */
.page-indicator {
  position: fixed;
  bottom: 2.5vh;
  right: 3vw;
  z-index: 100;
  font-family: var(--font-caption);
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--color-umber);
  cursor: pointer;
  user-select: none;
  transition: color 0.3s ease, background 0.3s ease, border-color 0.3s ease;
  padding: 6px 10px;
  background: rgba(245, 230, 208, 0.8);
  border: 1px solid rgba(139, 115, 85, 0.2);
}

.page-indicator:hover {
  color: var(--color-saddle);
}

.page-current,
.page-separator,
.page-total {
  font-family: var(--font-caption);
}


/* ======================
   TABLE OF CONTENTS OVERLAY
   ====================== */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(44, 24, 16, 0.92);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.toc-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.toc-content {
  text-align: center;
  position: relative;
}

.toc-close {
  position: absolute;
  top: -3rem;
  right: -2rem;
  background: none;
  border: none;
  font-family: var(--font-caption);
  font-size: 2rem;
  color: var(--color-brass);
  cursor: pointer;
  transition: color 0.3s ease;
  line-height: 1;
}

.toc-close:hover {
  color: var(--color-parchment);
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.toc-link {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  color: var(--color-brass);
  text-decoration: none;
  transition: color 0.3s ease;
  letter-spacing: 0.02em;
}

.toc-link:hover {
  color: var(--color-parchment);
}

.toc-link:visited {
  color: var(--color-copper);
}


/* ======================
   BOUNCE-ENTER ANIMATIONS
   ====================== */

/* Default: hidden before animation triggers */
.animate-bounce-up,
.animate-bounce-left,
.animate-fade-up,
.animate-scale-in {
  opacity: 0;
  will-change: transform, opacity;
}

/* Activated state */
.animate-bounce-up.animated {
  animation: bounceUp 600ms var(--ease-bounce) forwards;
}

.animate-bounce-left.animated {
  animation: bounceLeft 500ms var(--ease-bounce) forwards;
  animation-delay: 200ms;
}

.animate-fade-up.animated {
  animation: fadeUp 400ms var(--ease-bounce) forwards;
  animation-delay: 350ms;
}

.animate-scale-in.animated {
  animation: scaleIn 700ms var(--ease-bounce) forwards;
}

/* Drop cap animation */
.drop-cap {
  display: inline-block;
  transform-origin: bottom left;
}

@keyframes bounceUp {
  0% {
    opacity: 0;
    transform: translateY(40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceLeft {
  0% {
    opacity: 0;
    transform: translateX(-30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeUp {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  100% {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes dropCapBounce {
  0% {
    transform: rotate(-5deg) scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

/* Spread transition opacity dip */
.spread {
  transition: opacity 50ms ease;
}

/* Reduced motion fallback */
@media (prefers-reduced-motion: reduce) {
  .animate-bounce-up,
  .animate-bounce-left,
  .animate-fade-up,
  .animate-scale-in {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .animate-bounce-up.animated,
  .animate-bounce-left.animated,
  .animate-fade-up.animated,
  .animate-scale-in.animated {
    animation: simpleFade 300ms ease forwards;
  }

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


/* ======================
   STAGGER DELAYS FOR GALLERY GRID
   ====================== */
.grid-item.animate-bounce-up.animated {
  animation-delay: calc(var(--stagger, 0) * 100ms);
}


/* ======================
   RESPONSIVE (< 768px)
   ====================== */
@media (max-width: 768px) {
  /* Spine disappears on mobile */
  .spine-ornament {
    display: none;
  }

  /* Spreads become single-column stacks */
  .spread {
    height: auto;
    min-height: 100vh;
  }

  .spread-inner {
    flex-direction: column;
  }

  /* Cover */
  .cover-title-block {
    top: auto;
    bottom: 15vh;
    left: 5vw;
    right: 5vw;
    text-align: center;
    padding: 1.5rem 2rem;
  }

  .cover-spine-text {
    display: none;
  }

  /* Feature */
  .feature-left,
  .feature-right {
    width: 100%;
    padding: 3vh 5vw;
  }

  .feature-left {
    min-height: 50vh;
  }

  .feature-image-container {
    max-width: 90%;
  }

  /* Gallery */
  .gallery-left,
  .gallery-right {
    width: 100%;
    padding: 3vh 5vw;
  }

  .photo-grid {
    max-width: 100%;
  }

  /* Essay */
  .essay-content {
    flex-direction: column;
    gap: 0;
  }

  .spread-essay .spread-inner {
    padding: 4vh 5vw;
  }

  .essay-title {
    font-size: clamp(1.8rem, 6vw, 2.5rem);
  }

  /* Colophon */
  .colophon-content {
    padding: 4vh 5vw;
  }

  /* Page indicator */
  .page-indicator {
    bottom: 1.5vh;
    right: 2vw;
  }
}

/* ======================
   COLOPHON COLOR OVERRIDES
   (dark background needs light brackets)
   ====================== */
.spread-colophon .corner-bracket.corner-tl,
.spread-colophon .corner-bracket.corner-tr,
.spread-colophon .corner-bracket.corner-bl,
.spread-colophon .corner-bracket.corner-br {
  border-color: rgba(196, 168, 130, 0.5);
}
