/* ==========================================================================
   Full-viewport layout: экран заполнен, «воздух» → в размер контента (cqh/cqw)
   ========================================================================== */

:root {
  --bg-void: #ececec;
  --board-casing: #ffffff;
  --panel-seam: #d9dada;
  --accent-green: #3b9a38;
  --accent-lime: #88bd2f;
  --text-primary: #2b2a29;
  --text-muted: #898989;
  --rivet: #d9dada;

  --board-pad: clamp(6px, 1vmin, 24px);
  --panel-radius: clamp(8px, 1vmin, 22px);
  --pad-x: clamp(12px, 1.8vmin, 40px);
  --pad-y: clamp(8px, 1.1vmin, 20px);
  --gap: clamp(4px, 0.7vmin, 12px);
  --accent-bar: clamp(5px, 0.65vmin, 12px);
  --bar-h: clamp(12px, 1.8vmin, 28px);
  --mark-size: clamp(26px, 2.8vmin, 44px);

  --fs-ui: clamp(11px, 1.25vmin, 18px);
  --fs-meta: clamp(11px, 1.2vmin, 16px);
}

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

html {
  width: 100%;
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg-void);
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text-primary);
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(
      90deg,
      rgba(136, 189, 47, 0.10) 0%,
      rgba(59, 154, 56, 0.08) var(--day-progress, 0%),
      rgba(255, 255, 255, 0) var(--day-progress, 0%),
      rgba(255, 255, 255, 0) 100%
    ),
    var(--board-casing);
  padding: var(--board-pad);
  transition: background 0.6s ease;
}

.rivet {
  position: absolute;
  width: clamp(6px, 0.6vmin, 12px);
  height: clamp(6px, 0.6vmin, 12px);
  border-radius: 50%;
  background: var(--rivet);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  z-index: 2;
}
.rivet.tl { top: var(--board-pad); left: var(--board-pad); }
.rivet.tr { top: var(--board-pad); right: var(--board-pad); }
.rivet.bl { bottom: var(--board-pad); left: var(--board-pad); }
.rivet.br { bottom: var(--board-pad); right: var(--board-pad); }

/*
  Сетка плотнее: hero и progress делят остаток скромно.
  Контент внутри растёт через container queries → меньше «пустой середины».
*/
.panel {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows:
    auto
    auto
    minmax(0, 1fr)
    auto
    minmax(0, 0.55fr)
    auto;
  background: rgba(248, 248, 246, 0.97);
  border-radius: var(--panel-radius);
  border: 1px solid var(--panel-seam);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(43, 42, 41, 0.09);
}

.panel:has(.holiday-row[hidden]) {
  grid-template-rows:
    auto
    minmax(0, 1fr)
    auto
    minmax(0, 0.55fr)
    auto;
}

/* ---------- Шапка ---------- */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: var(--pad-y) var(--pad-x);
  border-bottom: 1px solid var(--panel-seam);
  min-width: 0;
}

.eyebrow {
  font-size: var(--fs-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.flap {
  font-family: "Courier New", Courier, monospace;
  font-weight: 800;
  color: var(--accent-green);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

#current-time {
  font-size: clamp(13px, 1.6vmin, 22px);
  text-align: right;
}

/* ---------- Праздник ---------- */
.holiday-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.2vmin, 20px);
  padding: var(--pad-y) var(--pad-x);
  border-bottom: 1px solid var(--panel-seam);
  border-left: var(--accent-bar) solid var(--accent-lime);
  background:
    linear-gradient(
      90deg,
      rgba(136, 189, 47, 0.22) 0%,
      rgba(59, 154, 56, 0.10) 42%,
      rgba(255, 255, 255, 0.35) 100%
    );
  min-width: 0;
}

.holiday-row[hidden] {
  display: none !important;
}

.holiday-copy {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.holiday-label {
  font-size: clamp(11px, 1.35vmin, 18px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-green);
  font-weight: 800;
  margin-bottom: 2px;
  line-height: 1.25;
}

.holiday-name {
  margin: 0;
  font-size: clamp(16px, 2.6vmin, 40px);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.holiday-name.flip {
  animation: flapChange 0.45s ease;
}

.holiday-meta {
  flex: 0 0 auto;
  padding: clamp(4px, 0.55vmin, 10px) clamp(8px, 1vmin, 14px);
  border-radius: 999px;
  background: rgba(59, 154, 56, 0.14);
  border: 1px solid rgba(59, 154, 56, 0.28);
  font-size: var(--fs-meta);
  color: var(--accent-green);
  font-weight: 800;
  white-space: nowrap;
}

/* ---------- Фаза + небо (sun arc) ---------- */
.phase-block {
  container-type: size;
  container-name: phase;
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: 0;
  border-bottom: 1px solid var(--panel-seam);
  overflow: hidden;
  isolation: isolate;
}

.sky-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  transition: background 0.35s linear;
  background: linear-gradient(to bottom, rgb(10, 15, 40), rgb(20, 25, 60), rgb(30, 35, 70));
}

#sun {
  --sun-size: clamp(28px, min(12cqh, 10cqi), 72px);
  width: var(--sun-size);
  height: var(--sun-size);
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 90%;
  background: radial-gradient(circle at 30% 30%, #fff7e6, #ffd700, #ff8c00);
  box-shadow: 0 0 40px #ffd700, 0 0 80px #ff8c00;
  transform: translate(-50%, -50%);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  will-change: left, top, opacity, box-shadow;
}

#sunlight {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(80px, 40cqh, 280px);
  height: clamp(80px, 40cqh, 280px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 220, 120, 0.45) 0%, rgba(255, 180, 60, 0.12) 45%, transparent 70%);
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  will-change: left, top, opacity;
  filter: blur(2px);
}

#moon {
  --moon-size: clamp(22px, min(9cqh, 7cqi), 52px);
  width: var(--moon-size);
  height: var(--moon-size);
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 90%;
  background: radial-gradient(circle at 35% 35%, #f5f5f5, #d0d0d0);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.3), inset -6px -6px 0 rgba(0, 0, 0, 0.1);
  transform: translate(-50%, -50%);
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  will-change: left, top, opacity;
}

#moon::before,
#moon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
}
#moon::before {
  width: 22%;
  height: 22%;
  top: 22%;
  left: 28%;
}
#moon::after {
  width: 14%;
  height: 14%;
  top: 52%;
  left: 52%;
}

#stars,
#clouds,
#birds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#stars { z-index: 1; }
#clouds { z-index: 2; }
#birds { z-index: 3; }

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.5s;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
  filter: blur(8px);
  transition: opacity 0.5s;
  will-change: transform, opacity;
}

.bird {
  position: absolute;
  width: clamp(18px, 4cqi, 32px);
  height: clamp(9px, 2cqi, 16px);
  opacity: 0;
  color: rgba(34, 38, 46, 0.82);
  transition: opacity 0.5s;
  will-change: transform, opacity;
}
.bird svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bird .left-wing,
.bird .right-wing {
  transform-box: fill-box;
  transform-origin: center;
  animation: wingBeat 1.15s ease-in-out infinite;
}
.bird .right-wing {
  animation-delay: -0.08s;
}

@keyframes wingBeat {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(-5deg) translateY(1.2px); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

/* Текст фазы поверх неба — не ломает сетку панели */
.sky-overlay {
  position: relative;
  z-index: 10;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 0.8vmin, 12px);
  padding: clamp(8px, 1.5vmin, 24px) var(--pad-x);
  text-align: center;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.18) 0%,
    rgba(0, 0, 0, 0.06) 40%,
    rgba(0, 0, 0, 0.22) 100%
  );
}

#phase-title {
  font-size: clamp(18px, 26cqh, 88px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  color: #fff;
  line-height: 1.08;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-shadow:
    0 2px 12px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(0, 0, 0, 0.25);
}

#phase-title.flip {
  animation: flapChange 0.45s ease;
}

@keyframes flapChange {
  0%   { transform: rotateX(0deg); opacity: 1; }
  45%  { transform: rotateX(85deg); opacity: 0.3; }
  55%  { transform: rotateX(85deg); opacity: 0.3; }
  100% { transform: rotateX(0deg); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #phase-title.flip,
  .holiday-name.flip {
    animation: none;
  }

  .bird .left-wing,
  .bird .right-wing {
    animation: none;
  }

  .star {
    animation: none !important;
  }
}

#encouragement {
  margin: 0;
  font-size: clamp(12px, 8cqh, 26px);
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.9);
  max-width: min(48ch, 92%);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

/* ---------- Счётчики ---------- */
.counters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
  align-items: stretch;
}

.counter {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: var(--pad-y) var(--pad-x);
  border-right: 1px solid var(--panel-seam);
  border-bottom: 1px solid var(--panel-seam);
}

.counter:last-child {
  border-right: none;
}

.counter.is-highlight {
  background:
    linear-gradient(
      160deg,
      rgba(136, 189, 47, 0.18),
      rgba(59, 154, 56, 0.06) 55%,
      transparent
    );
  box-shadow: inset 0 0 0 1px rgba(59, 154, 56, 0.12);
}

.counter-label {
  font-size: var(--fs-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 2px;
  line-height: 1.25;
}

.counter.is-highlight .counter-label {
  color: var(--accent-green);
  font-weight: 800;
}

.counter-value {
  font-size: clamp(24px, 12cqi, 72px);
  line-height: 1.05;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.counter-note {
  margin-top: var(--gap);
  font-size: clamp(12px, 1.4vmin, 18px);
  color: var(--text-muted);
  line-height: 1.3;
}

.counter-note.is-accent {
  display: inline-block;
  max-width: 100%;
  padding: clamp(5px, 0.7vmin, 10px) clamp(8px, 1vmin, 14px);
  border-radius: clamp(8px, 0.9vmin, 12px);
  font-weight: 800;
  font-size: clamp(12px, 1.45vmin, 20px);
  color: var(--text-primary);
  background: rgba(136, 189, 47, 0.16);
  border: 1px solid rgba(59, 154, 56, 0.28);
}

/* ---------- Прогресс ---------- */
.progress-wrap {
  container-type: size;
  container-name: progress;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--pad-y) var(--pad-x);
  border-bottom: 1px solid var(--panel-seam);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(236, 236, 236, 0.38));
  gap: var(--gap);
}

.progress-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(8px, 1.2vmin, 20px);
  flex-wrap: wrap;
  font-size: var(--fs-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  min-width: 0;
}

#progress-value {
  color: var(--accent-green);
  font-family: "Courier New", monospace;
  /* заполняет высоту блока прогресса */
  font-size: clamp(24px, 42cqh, 88px);
  line-height: 0.95;
  letter-spacing: -0.05em;
  text-shadow: 0 3px 14px rgba(59, 154, 56, 0.14);
}

.bar {
  position: relative;
  height: var(--bar-h);
  border-radius: 999px;
  background: var(--panel-seam);
  overflow: hidden;
  flex: 0 0 auto;
}

#bar-fill {
  position: relative;
  height: 100%;
  width: 0%;
  max-width: 100%;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.22) 0 12px,
      rgba(255, 255, 255, 0.05) 12px 24px
    ),
    linear-gradient(90deg, var(--accent-lime), var(--accent-green));
  transition: width 0.6s ease;
  box-shadow: 0 0 16px rgba(59, 154, 56, 0.2);
}

#bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: clamp(14px, 2vmin, 28px);
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75));
  filter: blur(1px);
}

/* ---------- Рабочая неделя ---------- */
/* Иерархия: % → до выходных → день → служебный лейбл */
.week-block {
  display: flex;
  flex-direction: column;
  gap: clamp(3px, 0.45vmin, 8px);
  padding: var(--pad-y) var(--pad-x);
  background: rgba(136, 189, 47, 0.05);
  border-left: var(--accent-bar) solid rgba(136, 189, 47, 0.55);
  min-width: 0;
}

.week-eyebrow {
  font-size: clamp(10px, 1.05vmin, 14px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  line-height: 1.2;
  opacity: 0.9;
}

/* 3. Служебная строка дня — спокойная, мельче */
.week-day-line {
  margin: 0;
  font-size: clamp(12px, 1.35vmin, 17px);
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.35;
}

.week-day-name {
  color: var(--text-primary);
  font-weight: 700;
}

/* 2. До выходных — второй акцент */
.week-remaining-line {
  margin: 0 0 clamp(2px, 0.35vmin, 6px);
  font-size: clamp(15px, 1.85vmin, 24px);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.week-remaining-accent {
  font-weight: 800;
  color: var(--accent-green);
  font-variant-numeric: tabular-nums;
}

/* 1. Процент + подпись + полоса как единый показатель */
.week-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(3px, 0.4vmin, 6px);
  min-width: 0;
  margin-top: clamp(2px, 0.3vmin, 4px);
}

.week-progress-value {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(32px, 4.2vmin, 56px);
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--accent-green);
  font-variant-numeric: tabular-nums;
  line-height: 0.95;
  text-shadow: 0 2px 10px rgba(59, 154, 56, 0.12);
}

.week-progress-caption {
  font-size: clamp(11px, 1.2vmin, 15px);
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.25;
}

.week-bar {
  position: relative;
  width: 100%;
  height: clamp(10px, 1.25vmin, 16px);
  margin-top: clamp(1px, 0.2vmin, 3px);
  border-radius: 999px;
  background: var(--panel-seam);
  overflow: hidden;
  flex: 0 0 auto;
}

#week-bar-fill {
  height: 100%;
  width: 0%;
  max-width: 100%;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.18) 0 10px,
      rgba(255, 255, 255, 0.04) 10px 20px
    ),
    linear-gradient(90deg, var(--accent-lime), var(--accent-green));
  transition: width 0.6s ease;
  box-shadow: 0 0 12px rgba(59, 154, 56, 0.18);
}

/* ========== Телефон ========== */
@media (max-width: 700px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
  }

  .board {
    height: auto;
    min-height: 100dvh;
    max-height: none;
  }

  .panel {
    flex: 1 0 auto;
    min-height: calc(100dvh - 2 * var(--board-pad));
    grid-template-rows: auto auto auto auto auto auto;
  }

  .panel:has(.holiday-row[hidden]) {
    grid-template-rows: auto auto auto auto auto;
  }

  .progress-wrap,
  .counter {
    container-type: normal;
  }

  #phase-title {
    font-size: clamp(20px, 6.5vw, 34px);
  }

  #encouragement {
    font-size: clamp(13px, 3.6vw, 16px);
  }

  .counter-value {
    font-size: clamp(28px, 10vw, 48px);
  }

  #progress-value {
    font-size: clamp(32px, 12vw, 56px);
  }

  .holiday-row {
    flex-wrap: wrap;
  }

  .holiday-name {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: clamp(16px, 5vw, 22px);
  }

  .counters {
    grid-template-columns: 1fr;
  }

  .counter {
    border-right: none;
  }

  .phase-block {
    min-height: 140px;
  }

  .sky-overlay {
    padding-block: 14px;
  }

  .week-day-line {
    font-size: clamp(12px, 3.2vw, 15px);
  }

  .week-remaining-line {
    font-size: clamp(15px, 4.2vw, 20px);
  }

  .week-progress-value {
    font-size: clamp(30px, 9vw, 44px);
  }

  .week-bar {
    height: clamp(10px, 2.4vw, 14px);
  }
}

@media (max-width: 380px) {
  .holiday-row {
    flex-direction: column;
    align-items: stretch;
  }

  .holiday-meta {
    align-self: flex-start;
  }

  .row {
    flex-wrap: wrap;
  }

  #current-time {
    width: 100%;
    text-align: left;
  }
}

/* Низкий landscape — меньше доля progress */
@media (max-height: 650px) and (min-width: 701px) {
  .panel {
    grid-template-rows:
      auto
      auto
      minmax(0, 1fr)
      auto
      minmax(0, 0.4fr)
      auto;
  }

  #phase-title {
    font-size: clamp(18px, 26cqh, 48px);
  }

  #progress-value {
    font-size: clamp(20px, 36cqh, 48px);
  }
}

/* Fallback без container queries */
@supports not (font-size: 1cqh) {
  #phase-title {
    font-size: clamp(22px, 5.5vmin, 72px);
  }

  #encouragement {
    font-size: clamp(13px, 2vmin, 24px);
  }

  #progress-value {
    font-size: clamp(28px, 6vmin, 80px);
  }

  .counter-value {
    font-size: clamp(26px, 5.5vmin, 64px);
  }
}
