/* Палитра, шрифты, сброс. Значения цветов — из docs/art-guide.md, раздел 1. */

@font-face {
  font-family: 'PT Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../../assets/fonts/pt-mono-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../../assets/fonts/pt-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../../assets/fonts/pt-serif-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../../assets/fonts/pt-serif-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../../../assets/fonts/pt-serif-700-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../../../assets/fonts/pt-serif-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../../../assets/fonts/pt-serif-400italic-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../../../assets/fonts/pt-serif-400italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}

:root {
  --paper: #e8dcc4;
  --paper-dark: #d4c4a0;
  --photo: #d6c595;
  --ink: #2b2118;
  /* Вторичный текст светлее чернил ровно настолько, чтобы удержать контраст 7:1. */
  --ink-soft: #4a3d2d;
  --ink-faded: #6b5b47;
  --accent: #a3312b;
  --stamp-blue: #1f3a5f;
  --lamp: #fff3d6;
  --shadow: rgba(43, 33, 24, 0.35);
  --desk: #17120d;
  --desk-edge: #0b0805;
  /* Цвет текста и рамок, лежащих прямо на столе, а не на бумаге. */
  --on-desk: #e8dcc4;
  --on-desk-line: rgba(232, 220, 196, 0.4);
  --rule: rgba(43, 33, 24, 0.22);
  --grain: 0.06;
  --lamp-strength: 0.5;

  --font-mono: 'PT Mono', ui-monospace, 'Courier New', monospace;
  --font-serif: 'PT Serif', Georgia, serif;

  --gap: 14px;
  --radius: 2px;
  --stamp-red: #a3312b;
}

/* «Светлый бланк»: бумага почти белая, чернила чернее, свет и зерно убраны. */
:root[data-theme='blank'] {
  --paper: #fcf8ee;
  --paper-dark: #efe8d8;
  --photo: #e4dcc6;
  --ink: #14100a;
  --ink-soft: #14100a;
  --ink-faded: #3f3527;
  --accent: #8e2019;
  --stamp-blue: #16304f;
  --lamp: #ffffff;
  --shadow: rgba(20, 16, 10, 0.25);
  --desk: #b9b0a0;
  --desk-edge: #8f887a;
  --on-desk: #14100a;
  --on-desk-line: rgba(20, 16, 10, 0.4);
  --rule: rgba(20, 16, 10, 0.3);
  --grain: 0.02;
  --lamp-strength: 0.12;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Панели объявлены как flex/grid, и без !important атрибут hidden на них не работает. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--desk-edge);
}

body {
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Картинки не перетаскиваются мышью и не открывают меню по долгому тапу. */
img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Общий слой зерна: накладывается на любую бумажную поверхность. */
.paper {
  position: relative;
  background: var(--paper);
  color: var(--ink);
}

.paper::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain);
  mix-blend-mode: multiply;
  background-image: var(--grain-url);
  background-size: 180px 180px;
  border-radius: inherit;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
