@font-face {
  font-family: 'Spencerian';
  src: url('assets/spencerian.ttf') format('truetype');
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

::selection {
  background: rgba(180, 140, 255, 0.35);
  color: #fff;
}

body {
  background: #111;
  color: #7a5a2c;
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  font-size: 15px;
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  display: none;
}

#pt-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

#no-webgpu {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #1a1a2e 100%);
  background-size: 300% 300%;
  animation: gradientShift 20s ease infinite;
}

#no-webgpu.visible {
  display: block;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- Header bar --- */
#overlay {
  position: relative;
  z-index: 1;
  padding: 2rem 3rem;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
}

#overlay header,
#overlay nav {
  pointer-events: auto;
}

#overlay > header h1 {
  font-family: 'Spencerian', Georgia, serif;
  font-size: 3.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7), 0 0 4px rgba(0, 0, 0, 0.5);
}

#overlay > header h1 a {
  color: inherit;
  text-decoration: none;
}

#overlay nav {
  display: flex;
  gap: 1.8rem;
}

#overlay nav a {
  color: #aaa;
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  transition: color 0.15s;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

#overlay nav a:hover {
  color: #d4cdc4;
  border-bottom-color: #d4cdc4;
}

#overlay nav a.active {
  color: #d4cdc4;
  border-bottom-color: rgba(212, 205, 196, 0.5);
}

/* --- Control buttons --- */
#controls {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  gap: 0.4rem;
}

#controls button {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #888;
}

#controls button:hover {
  background: rgba(0, 0, 0, 0.6);
  color: #d4cdc4;
}

#water-btn.off {
  color: #333;
  border-color: rgba(255, 255, 255, 0.05);
}

/* --- Slider controls --- */
.ctrl-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-right: 0.4rem;
}

.ctrl-slider {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ctrl-slider label {
  font: 11px monospace;
  color: #666;
  min-width: 72px;
  text-align: right;
  user-select: none;
}

.ctrl-slider label span {
  color: #999;
}

.ctrl-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 64px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.ctrl-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  background: #888;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.ctrl-slider input[type="range"]::-webkit-slider-thumb:hover {
  background: #bbb;
}

.ctrl-slider input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: #888;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.ctrl-slider input[type="range"]::-moz-range-thumb:hover {
  background: #bbb;
}

.pause-icon {
  display: flex;
  gap: 3px;
}

.pause-icon::before,
.pause-icon::after {
  content: '';
  display: block;
  width: 2px;
  height: 10px;
  background: currentColor;
}

.play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
  margin-left: 2px;
}

/* --- Content panel --- */
#content {
  display: none;
  pointer-events: auto;
  margin-top: 1.5rem;
  max-height: calc(100vh - 9rem);
  overflow-y: auto;
  scrollbar-width: none;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

#content::-webkit-scrollbar {
  display: none;
}

#content.visible {
  display: block;
}

.content-inner {
  background: none;
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  padding: 1.5rem 2rem;
  max-width: 640px;
  margin: 0 auto;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.7);
}

/* --- Back link --- */
.back-link {
  display: inline-block;
  color: #777;
  text-decoration: none;
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.03em;
  transition: color 0.15s;
}

.back-link:hover {
  color: #d4cdc4;
}

/* --- API activity sections --- */
.api-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.api-section h3 {
  font-size: 1.2rem;
  font-weight: 400;
  color: #b0a99f;
  margin-bottom: 1rem;
  text-transform: none;
  letter-spacing: 0;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  padding: 0.3rem 0;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.06);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.activity-thumb.film-poster {
  width: 30px;
  height: 44px;
}

.activity-title {
  display: block;
  font-size: 0.85rem;
  color: #b0a99f;
}

.activity-sub {
  display: block;
  font-size: 0.75rem;
  color: #c46b68;
}

a.activity-item:hover .activity-title {
  color: #d4cdc4;
}

/* --- Favorite films grid --- */
.favorites-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.favorite-film {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
  gap: 0.4rem;
}

.favorite-film img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.15s;
}

.favorite-film:hover img {
  border-color: rgba(255, 255, 255, 0.4);
}

.favorite-film span {
  font-size: 0.7rem;
  color: #999;
  text-align: center;
  line-height: 1.3;
}

.favorite-film:hover span {
  color: #d4cdc4;
}

.muted {
  font-size: 0.8rem;
  color: #444;
  font-style: italic;
}

/* --- Article list --- */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.article-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.75rem 0;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.1);
  transition: border-color 0.15s;
}

.article-card:last-child {
  border-bottom: none;
}

.article-card:hover {
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.article-card time {
  font-size: 0.75rem;
  color: #666;
}

.article-card h3 {
  font-size: 1rem;
  font-weight: 400;
  margin: 0.2rem 0;
  color: #8f7049;
}

.article-card:hover h3 {
  color: #d4cdc4;
}

.article-card p {
  font-size: 0.85rem;
  color: #888;
  margin: 0;
}

/* --- Article body typography --- */
article h1 {
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

article h2 {
  font-size: 1.1rem;
  font-weight: 400;
  margin: 2rem 0 0.75rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 0.4rem;
  color: #b0a99f;
}

article h3 {
  font-size: 1rem;
  font-weight: 400;
  margin: 1.5rem 0 0.5rem;
  color: #a09890;
}

article p {
  line-height: 1.8;
  margin-bottom: 1rem;
  color: #b0a99f;
}

article a {
  color: #c9a0ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 160, 255, 0.3);
  transition: border-color 0.15s, color 0.15s;
}

article a:hover {
  color: #d4b8f0;
  border-bottom-color: #d4b8f0;
}

article ul, article ol {
  margin: 0 0 1rem 1.5rem;
  line-height: 1.8;
  color: #b0a99f;
}

article blockquote {
  border-left: 2px solid #555;
  margin: 1.5rem 0;
  padding: 0.5rem 1.2rem;
  color: #999;
  font-style: italic;
}

article code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.15em 0.4em;
  font-size: 0.9em;
  color: #e0c0ff;
}

article pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

article pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #8a7152;
}

article img {
  max-width: 100%;
  margin: 1rem 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

article hr {
  border: none;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
  margin: 2rem 0;
}

/* --- Content h2 (section titles like "Writings") --- */
.content-inner > h2 {
  font-size: 1.6rem;
  font-weight: 400;
  color: #c4bdb4;
}

/* --- Mobile --- */
@media (max-width: 768px) {
  #overlay {
    padding: 1.5rem;
    gap: 0.5rem;
    flex-direction: column;
    flex-wrap: nowrap;
    height: 100dvh;
  }

  #overlay > header h1 {
    font-size: 2rem;
    color: #d4cdc4;
  }

  #overlay nav {
    gap: 1rem;
    background: rgba(0, 0, 0, 0.75);
    padding: 0.5rem 0.75rem;
    border-radius: 0;
  }

  #overlay nav a {
    font-size: 0.85rem;
    color: #d4cdc4;
    text-shadow: none;
  }

  #overlay nav a.active {
    color: #f0ebe4;
  }

  #content {
    margin-top: 0.5rem;
    max-height: none;
    flex: 1 1 0;
    min-height: 0;
    overscroll-behavior-y: none;
  }

  .content-inner {
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 0;
    text-shadow: none;
  }

  .content-inner > h2 {
    color: #d6cfc6;
  }

  article p,
  article ul,
  article ol {
    color: #d4cdc4;
  }

  article h2 {
    color: #c9c2b9;
  }

  article h3 {
    color: #bdb6ad;
  }

  article blockquote {
    color: #b8b1a8;
  }

  .article-card h3 {
    color: #a8894a;
  }

  .article-card p {
    color: #b0a99f;
  }

  .article-card time {
    color: #888;
  }

  .api-section h3 {
    color: #c4bdb4;
  }

  .activity-title {
    color: #c4bdb4;
  }

  .activity-sub {
    color: #d47370;
  }

  .muted {
    color: #666;
  }
}

@media (prefers-reduced-motion: reduce) {
  #pt-canvas {
    opacity: 0.5;
  }
}
