@font-face {
  font-family: 'Monomakh';
  src: url('../assets/fonts/MonomakhPeredyshka.ttf') format('truetype');
  font-display: block;
}

@font-face {
  font-family: 'Alegreya';
  src: url('../assets/fonts/Alegreya.ttf') format('truetype');
  font-weight: 400 900;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Alegreya';
  src: url('../assets/fonts/Alegreya-Italic.ttf') format('truetype');
  font-weight: 400 900;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: 'Pirata One';
  src: url('../assets/fonts/PirataOne-Regular.ttf') format('truetype');
  font-display: block;
}

@property --c1 {
  syntax: '<color>';
  inherits: true;
  initial-value: #e0574a;
}

@property --c2 {
  syntax: '<color>';
  inherits: true;
  initial-value: #8e1c16;
}

:root {
  --soot: #17110e;
  --soot-deep: #0d0907;
  --stone: #2a2420;
  --parchment: #e8d9b5;
  --parchment-dim: #c2b08b;
  --parchment-faint: #918168;
  --ink: #2e2014;
  --ink-soft: #5c4631;
  --ink-faint: #8a7356;
  --gold: #c9a04e;
  --gold-light: #f1d58a;
  --gold-deep: #8c6a2a;
  --gold-line: rgb(201 160 78 / 0.34);
  --gold-hair: rgb(201 160 78 / 0.16);
  --vermilion: #b3261e;
  --vermilion-light: #d9473c;
  --gold-leaf: linear-gradient(160deg, #f8e6a6 0%, #d6ae5c 40%, #a47c34 72%, #e5c47c 100%);
  --font-display: 'Monomakh', 'Alegreya', serif;
  --font-text: 'Alegreya', Georgia, serif;
  --font-numerals: 'Pirata One', 'Alegreya', serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.24 0 0 0 0 0.16 0 0 0 0 0.09 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --stains: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.011' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.3 0 0 0 0 0.13 0 0 0 0.9 -0.32'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  --flourish: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 12'%3E%3Cdefs%3E%3ClinearGradient id='f'%3E%3Cstop offset='0' stop-color='%23c9a04e' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23c9a04e'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 6H60' stroke='url(%23f)' stroke-width='1'/%3E%3Ccircle cx='64' cy='6' r='1.4' fill='%23c9a04e'/%3E%3Cpath d='M68 6l5-5 5 5-5 5z' fill='none' stroke='%23c9a04e' stroke-width='1.2'/%3E%3Cpath d='M71 6l2-2 2 2-2 2z' fill='%23f1d58a'/%3E%3C/svg%3E");

  color-scheme: dark;
}

/* Финифти дозора: --focus-1 светлый тон, --focus-2 глубокий */
[data-accent='gules'] {
  --focus-1: #e0574a;
  --focus-2: #8e1c16;
}

[data-accent='purpure'] {
  --focus-1: #b06ac4;
  --focus-2: #55206a;
}

[data-accent='or'] {
  --focus-1: #f1d58a;
  --focus-2: #a5772c;
}

[data-phase='focus'] {
  --c1: var(--focus-1);
  --c2: var(--focus-2);
}

[data-phase='short'] {
  --c1: #7cc7b0;
  --c2: #24685b;
}

[data-phase='long'] {
  --c1: #8aa6ef;
  --c2: #22397f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--soot);
  color: var(--parchment);
  font: 15px/1.5 var(--font-text);
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
  transition: --c1 0.9s var(--ease), --c2 0.9s var(--ease);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--gold-hair);
  border: 2px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}

/* ---------- btn ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  background: rgb(23 17 14 / 0.62);
  color: var(--parchment);
  font: 600 15px/1 var(--font-text);
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s var(--ease), opacity 0.2s, filter 0.2s;
}

.btn:hover {
  border-color: var(--gold);
  background: rgb(42 36 32 / 0.8);
  color: var(--gold-light);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.btn__icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn__label {
  position: relative;
}

.btn--gold {
  border-color: #f3dc98;
  background: var(--gold-leaf);
  color: var(--ink);
  text-shadow: 0 1px 0 rgb(255 244 210 / 0.55);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.4), 0 8px 22px -10px rgb(201 160 78 / 0.8);
}

.btn--gold:hover {
  border-color: #fff0c0;
  background: var(--gold-leaf);
  color: var(--ink);
  filter: brightness(1.08);
}

.btn--enamel {
  border-color: transparent;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  color: #fbf1da;
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.35);
}

.btn--enamel:hover {
  border-color: transparent;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  color: #fff;
  filter: brightness(1.1);
}

.btn--ink {
  border-color: rgb(46 32 20 / 0.32);
  background: transparent;
  color: var(--ink);
}

.btn--ink:hover {
  border-color: var(--ink-soft);
  background: rgb(46 32 20 / 0.08);
  color: var(--ink);
}

.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--parchment-faint);
}

.btn--quiet:hover {
  border-color: transparent;
  background: transparent;
  color: var(--parchment-dim);
}

.btn--lg {
  min-height: 52px;
  padding: 0 28px;
  font-size: 17px;
}

.btn--sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13.5px;
}

.btn--sm .btn__icon {
  width: 16px;
  height: 16px;
}

/* Кольцо из воронёного железа с золотой каймой */
.btn--ring {
  width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  color: var(--gold);
  box-shadow: inset 0 0 0 3px rgb(17 12 10 / 0.9), inset 0 0 0 4px var(--gold-hair);
}

.btn--ring.btn--sm {
  width: 32px;
  min-height: 32px;
  box-shadow: none;
}

.btn--ink.btn--ring {
  color: var(--ink-soft);
}

/* Заливка, которая растёт, пока кнопку удерживают */
.btn__fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--c2), var(--c1));
  opacity: 0.45;
  transform: scaleX(0);
  transform-origin: left;
}

.btn--holding .btn__fill {
  transform: scaleX(1);
  transition: transform var(--hold-duration, 3s) linear;
}

/* ---------- seal (восковая печать) ---------- */

.seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 0;
  background: none;
  filter: drop-shadow(0 7px 10px rgb(0 0 0 / 0.55));
  transition: transform 0.2s var(--ease), opacity 0.2s;
}

button.seal:hover {
  transform: rotate(-5deg) scale(1.03);
}

button.seal:active {
  transform: scale(0.95);
}

.seal:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.seal__wax {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.seal__stop--light {
  stop-color: var(--c1);
}

.seal__stop--deep {
  stop-color: var(--c2);
}

.seal__rim {
  fill: none;
  stroke: rgb(0 0 0 / 0.3);
  stroke-width: 2.6;
}

.seal__shine {
  fill: none;
  stroke: rgb(255 240 220 / 0.22);
  stroke-width: 1.4;
}

.seal__icon {
  position: relative;
  display: grid;
  place-items: center;
  color: color-mix(in oklab, var(--c2) 72%, black);
  filter: drop-shadow(0 1px 0 rgb(255 235 210 / 0.3)) drop-shadow(0 -1px 0 rgb(0 0 0 / 0.35));
}

.seal__icon .btn__icon {
  width: 30px;
  height: 30px;
}

.seal--sm {
  width: 56px;
  height: 56px;
}

.seal--sm .seal__icon .btn__icon {
  width: 22px;
  height: 22px;
}

/* ---------- dial (циферблат-астролябия) ---------- */

.dial {
  --dial-size: 280px;
  position: relative;
  width: var(--dial-size);
  height: var(--dial-size);
  flex: none;
}

.dial__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dial__stop--c1 {
  stop-color: var(--c1);
}

.dial__stop--c2 {
  stop-color: var(--c2);
}

.dial__stop--gold {
  stop-color: var(--gold-light);
}

.dial__band {
  fill: rgb(13 9 7 / 0.62);
}

.dial__rim {
  fill: none;
}

.dial__motto {
  font-family: var(--font-numerals);
  font-size: 10.5px;
  fill: var(--gold);
}

.dial__tick {
  stroke: var(--gold);
  stroke-width: 0.7;
  opacity: 0.35;
}

.dial__tick--major {
  stroke-width: 1.5;
  opacity: 0.85;
}

.dial__halo {
  transform-box: view-box;
  transform-origin: 50% 50%;
  transform: scale(0.82);
  opacity: 0.45;
  transition-property: transform, opacity;
  transition-timing-function: ease-in-out;
}

.dial__halo--full {
  transform: scale(1.04);
  opacity: 0.85;
}

.dial__rose {
  fill: none;
  stroke: var(--gold);
  stroke-width: 0.7;
  opacity: 0.17;
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: dial-turn 300s linear infinite;
  animation-play-state: paused;
}

.dial--running .dial__rose {
  animation-play-state: running;
}

@keyframes dial-turn {
  to {
    transform: rotate(360deg);
  }
}

.dial__track {
  fill: none;
  stroke: rgb(0 0 0 / 0.55);
  stroke-width: 9;
}

.dial__glow,
.dial__arc {
  fill: none;
  stroke-dasharray: 100;
  transition: opacity 0.4s;
}

.dial__glow {
  stroke-width: 10;
  opacity: 0.7;
}

.dial__arc {
  stroke-width: 5;
  stroke-linecap: round;
}

.dial__spark {
  fill: #fff4d6;
  filter: drop-shadow(0 0 3px var(--c1)) drop-shadow(0 0 6px var(--gold-light));
  transition: opacity 0.4s;
}

.dial--empty .dial__arc,
.dial--empty .dial__glow,
.dial--empty .dial__spark {
  opacity: 0;
}

.dial__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.dial__phase {
  font: calc(var(--dial-size) * 0.078) / 1 var(--font-display);
  color: var(--c1);
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.7);
}

.dial__time {
  margin-top: calc(var(--dial-size) * 0.012);
  font: calc(var(--dial-size) * 0.235) / 0.95 var(--font-numerals);
  font-variant-numeric: tabular-nums;
  color: var(--gold-light);
  text-shadow: 0 0 22px rgb(201 160 78 / 0.38), 0 2px 6px rgb(0 0 0 / 0.75);
}

.dial__caption {
  margin-top: calc(var(--dial-size) * 0.02);
  min-height: 1.4em;
  font: italic calc(var(--dial-size) * 0.052) / 1.3 var(--font-text);
  color: var(--parchment-dim);
  text-shadow: 0 1px 6px rgb(0 0 0 / 0.8);
}

/* ---------- chip ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  background: transparent;
  color: var(--parchment-dim);
  font: 500 14px/1 var(--font-text);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.chip:hover {
  border-color: var(--gold);
  color: var(--parchment);
}

.chip--active,
.chip--active:hover {
  border-color: #f3dc98;
  background: var(--gold-leaf);
  color: var(--ink);
  font-weight: 700;
}

.chip__meta {
  margin-left: 6px;
  font-weight: 400;
  font-style: italic;
  opacity: 0.7;
}

/* ---------- frame (рамка рукописи) ---------- */

.frame {
  border: 1px solid var(--gold-line);
  background: rgb(17 12 10 / 0.66);
  box-shadow: inset 0 0 0 3px rgb(17 12 10 / 0.66), inset 0 0 0 4px var(--gold-hair);
  backdrop-filter: blur(8px);
}

/* ---------- parchment ---------- */

.parchment {
  border-radius: 3px;
  background:
    var(--grain),
    var(--stains),
    radial-gradient(ellipse at 50% 35%, #f3e8cb 0%, #e3cfa3 55%, #c8a76c 100%);
  color: var(--ink);
  box-shadow:
    inset 0 0 34px rgb(110 70 30 / 0.45),
    inset 0 0 3px rgb(80 50 20 / 0.6),
    0 18px 40px -18px rgb(0 0 0 / 0.85);
}

/* ---------- ornament (строка с завитками по бокам) ---------- */

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.ornament::before,
.ornament::after {
  content: '';
  width: 80px;
  height: 12px;
  flex: none;
  background: var(--flourish) center / contain no-repeat;
}

.ornament::after {
  transform: scaleX(-1);
}

/* ---------- rubric (киноварная буквица) ---------- */

.rubric {
  color: var(--vermilion-light);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
