/* ==========================================================================
   HIC SUNT DRACONES — токены дизайна
   Монохромный архивный нуар: почти чёрный фон, «бумажный» белый,
   костяной акцент, зерно плёнки, волосяные линейки.
   ========================================================================== */

:root {
  /* базовые токены ПУСК */
  --pusk-bg: #0a0a0b;
  --pusk-fg: #e9e6df;
  --pusk-surface: #131315;
  --pusk-muted: #8d8b86;
  --pusk-accent: #d8d0bc;

  --pusk-font-display: 'Prata', 'Times New Roman', serif;
  --pusk-font-body: 'Golos Text', system-ui, -apple-system, sans-serif;
  --pusk-font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  /* theme aliases (для классов библиотеки) */
  --background: var(--pusk-bg);
  --foreground: var(--pusk-fg);
  --card: var(--pusk-surface);
  --card-foreground: var(--pusk-fg);
  --popover: var(--pusk-surface);
  --popover-foreground: var(--pusk-fg);
  --primary: var(--pusk-accent);
  --primary-foreground: #0a0a0b;
  --secondary: #1a1a1c;
  --secondary-foreground: var(--pusk-fg);
  --muted: #17171a;
  --muted-foreground: var(--pusk-muted);
  --accent: var(--pusk-accent);
  --accent-foreground: #0a0a0b;
  --border: #2a2a2c;
  --input: #2a2a2c;
  --ring: var(--pusk-accent);
  --radius: 2px;
}

html {
  background: var(--pusk-bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--pusk-bg);
  color: var(--pusk-fg);
  font-family: var(--pusk-font-body);
  overflow-x: hidden;
}

::selection {
  background: var(--pusk-accent);
  color: #0a0a0b;
}

/* ------- типографика ------- */

.label-mono {
  font-family: var(--pusk-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--pusk-muted);
}

.display {
  font-family: var(--pusk-font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 0.98;
}

.prose-archive p {
  color: #cfccc4;
  line-height: 1.75;
}

.prose-archive p + p {
  margin-top: 1.15rem;
}

/* ------- линейки и сетки ------- */

.hairline {
  border-top: 1px solid rgba(233, 230, 223, 0.14);
}

.grid-lines {
  background-image:
    linear-gradient(to right, rgba(233, 230, 223, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(233, 230, 223, 0.055) 1px, transparent 1px);
  background-size: 72px 72px;
}

.rule-corners {
  position: relative;
}

.rule-corners::before,
.rule-corners::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(216, 208, 188, 0.5);
}

.rule-corners::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.rule-corners::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ------- зерно плёнки ------- */

.grain-overlay {
  position: fixed;
  inset: -50%;
  z-index: 70;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  animation: grain-shift 0.9s steps(3) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-3%, 2%); }
  66%  { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

.scrim {
  background:
    linear-gradient(180deg, rgba(10, 10, 11, 0.92) 0%, rgba(10, 10, 11, 0.6) 26%, rgba(10, 10, 11, 0.68) 62%, rgba(10, 10, 11, 0.95) 100%),
    radial-gradient(130% 100% at 50% 45%, rgba(10, 10, 11, 0.15) 0%, rgba(10, 10, 11, 0.7) 70%, #0a0a0b 100%);
}

/* ------- появление при скролле ------- */

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ------- бегущая строка ------- */

.marquee {
  display: flex;
  width: max-content;
  animation: marquee 46s linear infinite;
}

.marquee > * {
  flex: none;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (hover: hover) {
  .marquee-wrap:hover .marquee { animation-play-state: paused; }
}

/* ------- аккордеон ------- */

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] .plus { transform: rotate(45deg); }
.plus { transition: transform 0.3s ease; display: inline-block; }

/* ------- формы ------- */

.field {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(233, 230, 223, 0.2);
  border-radius: 0;
  padding: 0.85rem 0.9rem;
  color: var(--pusk-fg);
  font-family: var(--pusk-font-body);
  font-size: 0.95rem;
  transition: border-color 0.25s ease, background-color 0.25s ease;
}

.field::placeholder { color: #6f6d69; }

.field:focus {
  outline: none;
  border-color: var(--pusk-accent);
  background: rgba(233, 230, 223, 0.03);
}

.btn-archive {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--pusk-accent);
  color: var(--pusk-accent);
  background: transparent;
  font-family: var(--pusk-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.95rem 1.6rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.btn-archive:hover {
  background: var(--pusk-accent);
  color: #0a0a0b;
}

.link-underline {
  position: relative;
}

.link-underline::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -3px;
  height: 1px;
  width: 100%;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}

.link-underline:hover::after { transform: scaleX(1); }

/* внешняя ссылка на работу: постоянная тонкая линия и стрелка */
.link-ext {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-bottom: 1px solid rgba(233, 230, 223, 0.28);
  padding-bottom: 2px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.link-ext::after {
  content: '↗';
  font-size: 0.9em;
  line-height: 1;
}

.link-ext:hover {
  color: var(--pusk-accent);
  border-color: var(--pusk-accent);
}

/* ------- библиотечные блоки ------- */

#scramble-output { min-height: 1.2em; }

.spotlight-canvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ------- уважение к reduced motion ------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .grain-overlay,
  .marquee { animation: none !important; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
