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

/* ─── Font ─── */
@font-face {
  font-family: "ABCDiatype Bold";
  src: url("../fonts/ABCDiatype-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Ivory LL";
  src: url("../fonts/IvoryLLWeb_Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ─── Custom Properties ─── */
:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #999999;
  --color-border: #d0d0d0;
  --color-hover: #000000;

  --font-main: "ABCDiatype Bold", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-editorial: "Ivory LL", Georgia, serif;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 3rem;
  --space-xl: 5rem;

  --page-pad: 2.5rem;
}

/* ─── Base ─── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
}

img, video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ─── Typography ─── */
h1 {
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.25;
}

h3 {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

p {
  line-height: 1.55;
}

.text-muted {
  color: var(--color-muted);
}

/* ─────────────────────────────────────────────
   BOOK COVER — Homepage
   ───────────────────────────────────────────── */

.book-cover {
  display: flex;
  min-height: 100vh;
}

/* ─── Table of Contents (left panel) ─── */
.toc {
  width: 280px;
  flex-shrink: 0;
  padding: var(--page-pad);
  padding-right: var(--space-md);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border-right: 1px solid var(--color-border);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toc.is-hidden {
  transform: translateX(-100%);
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.cover-header {
  transition: opacity 0.3s ease;
}

.cover-header.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.toc-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: 0.15rem;
}

.toc-list a {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.55;
  display: block;
  transition: opacity 0.15s ease;
}

.toc-list a:hover {
  opacity: 0.5;
}

.toc-list a.active {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Cover (right panel / main area) ─── */
.cover {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.cover-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: var(--page-pad);
  gap: var(--space-sm);
}

.cover-title {
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.cover-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cover-menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
}

.cover-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FF4400;
}

.cover-image {
  width: 52%;
  max-width: 520px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  filter: invert(1) grayscale(0);
  transition: filter 2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.cover-image--grayscale {
  filter: invert(0) grayscale(1);
}

.cover-image--normal {
  filter: invert(0) grayscale(0);
}

.cover-center {
  text-align: center;
  max-width: 560px;
}

.cover-center h1 {
  font-size: 3.2rem;
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-sm);
}

.cover-center .cover-subtitle {
  font-size: 1rem;
  color: var(--color-muted);
  font-weight: 400;
  line-height: 1.5;
}

.cover-footer {
  padding: var(--page-pad);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* ─────────────────────────────────────────────
   INNER PAGES — Shared layout
   ───────────────────────────────────────────── */

.page-layout {
  display: flex;
  min-height: 100vh;
}

.page-sidebar {
  width: 280px;
  flex-shrink: 0;
  padding: var(--page-pad);
  padding-right: var(--space-md);
  border-right: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-back {
  font-size: 0.85rem;
  color: var(--color-muted);
  display: inline-block;
  margin-bottom: var(--space-lg);
  transition: color 0.15s ease;
}

.sidebar-back:hover {
  color: var(--color-text);
}

.page-main {
  flex: 1;
  padding: var(--page-pad);
  max-width: 860px;
}

/* ─── Section Heading ─── */
.section-heading {
  margin-bottom: var(--space-lg);
}

.section-heading h2 {
  font-weight: 300;
  font-size: 2rem;
}

/* ─── Project Grid ─── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  padding-bottom: var(--space-xl);
}

.project-card {
  display: block;
  position: relative;
  overflow: hidden;
}

.project-card__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f2f2f2;
  transition: opacity 0.25s ease;
}

.project-card:hover .project-card__image {
  opacity: 0.8;
}

.project-card__info {
  padding: var(--space-sm) 0 0;
}

.project-card__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.project-card__meta {
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* ─── Gallery / Featured ─── */
.gallery {
  padding: var(--space-md) 0 var(--space-xl);
}

.gallery-featured {
  cursor: pointer;
  position: relative;
  max-width: 720px;
}

.gallery-featured img,
.gallery-featured video {
  width: 100%;
  display: block;
}

.gallery-hint {
  padding: var(--space-xs) 0;
  font-size: 0.75rem;
  color: var(--color-muted);
}

/* ─── Carousel Overlay ─── */
.carousel-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.carousel-media {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-media img,
.carousel-media video {
  max-width: 88vw;
  max-height: 82vh;
  object-fit: contain;
}

.carousel-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.12s ease;
}

.carousel-flash.is-flashing {
  opacity: 1;
  transition: opacity 0.01s ease;
}

.carousel-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  cursor: pointer;
  z-index: 2;
  background: none;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.carousel-nav--prev {
  left: 0;
  cursor: w-resize;
}

.carousel-nav--next {
  right: 0;
  cursor: e-resize;
}

.carousel-text-slide {
  max-width: 560px;
  padding: var(--space-md);
  text-align: left;
  font-family: var(--font-editorial);
}

.carousel-text-slide h2 {
  font-family: var(--font-editorial);
  font-size: 1.6rem;
  font-weight: 400;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

.carousel-text-slide p {
  font-family: var(--font-editorial);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-muted);
  max-width: 480px;
}

.carousel-title {
  position: absolute;
  top: var(--page-pad);
  left: var(--page-pad);
  z-index: 3;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.carousel-close {
  position: absolute;
  top: var(--page-pad);
  right: var(--page-pad);
  z-index: 3;
  background: none;
  border: none;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.carousel-close:hover {
  color: var(--color-text);
}

.carousel-counter {
  position: absolute;
  bottom: var(--page-pad);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* ─── About Page ─── */
.about-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: start;
  margin-top: var(--space-lg);
}

.about-text p {
  max-width: 480px;
  margin-bottom: var(--space-sm);
}

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

.about-image img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #f2f2f2;
}

.about-details {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.about-details dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-xs) var(--space-md);
}

.about-details dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
}

.about-details dd {
  font-size: 0.9rem;
}

/* ─── Footer (inner pages) ─── */
.page-footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-muted);
  display: flex;
  justify-content: space-between;
}

/* ─────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────── */

@media (max-width: 900px) {
  .book-cover {
    flex-direction: column;
  }

  .toc {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md);
  }

  .toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-md);
    margin-top: var(--space-xs);
  }

  .toc-list li {
    margin-bottom: 0;
  }

  .cover-center h1 {
    font-size: 2.4rem;
  }

  .page-layout {
    flex-direction: column;
  }

  .page-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md);
  }

  .sidebar-back {
    margin-bottom: 0;
  }

  .page-main {
    padding: var(--space-md);
  }
}

@media (max-width: 600px) {
  .project-grid {
    grid-template-columns: 1fr;
  }

  .about-content {
    grid-template-columns: 1fr;
  }

  .about-image {
    order: -1;
  }

  .cover-center h1 {
    font-size: 1.8rem;
  }

  .toc-list a {
    font-size: 0.95rem;
  }

  .page-footer {
    flex-direction: column;
    gap: var(--space-xs);
  }

  .carousel-media img,
  .carousel-media video {
    max-width: 95vw;
    max-height: 75vh;
  }
}
