/* ═══════════ calendar.css — модуль «Календарь» (.cal-) ═══════════
   Крафт-бумага, тушь и синий чертёж. Цвет события приходит в --ev, цвет метки в --c. */

.cal { --ev: var(--blue); min-width: 0; }
.cal .page-head { margin-bottom: 16px; }

/* ───────── Метки ───────── */
.cal-tag { --c: var(--ink-2); display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 5px; font-size: 12px; font-weight: 600; line-height: 1.35;
  color: color-mix(in srgb, var(--c) 82%, var(--ink)); background: color-mix(in srgb, var(--c) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--c) 34%, transparent); white-space: nowrap; }
.cal-tag-status { border-radius: 99px; font-weight: 500; }
.cal-tag-vec { border-radius: 99px; padding: 3px 10px; }

/* ───────── Ближайшее ───────── */
.cal-next { margin-bottom: 18px; }
.cal-next-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cal-next-today { font-size: 13px; color: var(--muted); }
.cal-next-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cal-next-item { text-align: left; font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--ev); border-radius: var(--radius); padding: 10px 12px 12px; }
.cal-next-item:hover { border-color: var(--ink); border-top-color: var(--ev); }
.cal-next-rel { font-family: var(--display); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--blue); font-weight: 600; }
.cal-next-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cal-next-sub { font-size: 13px; color: var(--muted); }
.cal-next-none { margin: 0; }

/* ───────── Сезон: переключатель и тема ───────── */
.cal-seasons { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: 14px; }
.cal-seasons::-webkit-scrollbar { display: none; }
.cal-season-btn { flex: none; display: inline-flex; align-items: baseline; gap: 6px; font: 600 15px var(--display); letter-spacing: .03em; padding: 6px 12px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2); cursor: pointer; }
.cal-season-btn small { font: 500 11px var(--font); color: var(--blue); text-transform: uppercase; letter-spacing: .08em; }
.cal-season-btn:hover { border-color: var(--ink); }
.cal-season-btn.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cal-season-btn.on small { color: #A9B4F5; }
.cal-season-note { color: var(--muted); font-size: 14px; margin: -4px 0 12px; }

.cal-theme { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 28px; align-items: start; margin-bottom: 14px; padding: 18px 20px;
  border: 1.5px solid var(--ink); border-radius: var(--radius); color: var(--ink);
  background: var(--paper-2) repeating-linear-gradient(0deg, transparent 0 23px, rgba(36,56,200,.07) 23px 24px), repeating-linear-gradient(90deg, transparent 0 23px, rgba(36,56,200,.07) 23px 24px); }
.cal-theme-title { font-size: 30px; text-transform: uppercase; color: var(--blue-dk); margin: 6px 0 8px; }
.cal-theme-q { font-size: 16px; margin: 0 0 6px; max-width: 640px; }
.cal-theme-verse { font-size: 14px; color: var(--blue-dk); font-style: italic; margin: 8px 0 0; max-width: 640px; }
.cal-theme-link { font-size: 14px; font-weight: 600; }
.cal-theme-side { display: flex; flex-direction: column; gap: 14px; align-items: flex-end; }
.cal-theme-stats { display: flex; gap: 22px; }
.cal-theme-stats .stat b { font-size: 28px; }
.cal-vectors { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 440px; }
.cal-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.cal-legend-now { color: var(--blue); }

/* ───────── Лента сезона ───────── */
.cal-tl { display: flex; flex-direction: column; }
.cal-tl-month { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 0 18px; }
.cal-tl-label { display: flex; flex-direction: column; padding: 14px 0 10px; text-align: right; }
.cal-tl-label b { font-family: var(--display); font-size: 19px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; }
.cal-tl-label span { font-size: 12px; color: var(--muted); }
.cal-tl-label small { font-size: 12px; color: var(--blue); margin-top: 4px; }
.cal-tl-month.is-past .cal-tl-label b { color: var(--muted); }
.cal-tl-month.is-cur .cal-tl-label b { color: var(--blue); }
.cal-tl-items { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 12px 0 12px 22px; border-left: 2px solid var(--ink); min-width: 0; }
.cal-tl-month.is-past .cal-tl-items { border-left-color: var(--line); }
.cal-tl-month + .cal-tl-month .cal-tl-items { border-top: 1px solid var(--line-2); }
.cal-tl-items > .cal-big, .cal-tl-items > .cal-row { position: relative; }
.cal-tl-items > .cal-big::before, .cal-tl-items > .cal-row::before { content: ''; position: absolute; left: -23px; top: 22px; width: 18px; height: 2px; background: var(--ev); }
.cal-tl-empty { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-height: 30px; }
.cal-tl-month.is-empty .cal-tl-label { padding: 8px 0 6px; }
.cal-tl-month.is-empty .cal-tl-items { padding: 6px 0 6px 22px; }

/* Линия «сегодня» */
.cal-today { position: relative; display: flex; align-items: center; height: 26px; margin: 2px 0; }
.cal-today::before { content: ''; position: absolute; left: -30px; right: 0; top: 50%; height: 2px; background: var(--blue); }
.cal-today-label { position: relative; background: var(--blue); color: #fff; font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 4px; }
.cal-tl .cal-today::after { content: ''; position: absolute; left: -30px; top: 50%; width: 12px; height: 12px; margin-top: -6px; background: var(--blue); transform: rotate(45deg); }

/* Крупная карточка опорного события */
.cal-big { background: var(--card); border: 1.5px solid color-mix(in srgb, var(--ev) 55%, var(--ink)); background: color-mix(in srgb, var(--ev) 6%, var(--card)); border-radius: var(--radius); padding: 14px 16px 14px; box-shadow: var(--shadow); min-width: 0; }
.cal-big.is-past { opacity: .62; box-shadow: none; border-color: var(--line); }
.cal-big.is-now { outline: 2px solid var(--blue); outline-offset: 2px; }
.cal-big-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-rel { font-size: 13px; color: var(--blue); font-weight: 600; }
.cal-big-title { font-size: 22px; text-transform: uppercase; margin: 8px 0 10px; overflow-wrap: anywhere; }
.cal-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0 0 12px; font-size: 14px; }
.cal-meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding-top: 2px; }
.cal-meta dd { margin: 0; overflow-wrap: anywhere; }
.cal-ready { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); margin-bottom: 12px; }
.cal-ready-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.cal-ready-row b { font-family: var(--display); font-size: 16px; color: var(--blue-dk); }
.cal-ready small { font-size: 12px; }
.cal-big-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Компактная строка */
.cal-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; min-width: 0;
  background: color-mix(in srgb, var(--ev) 6%, var(--card)); border: 1px solid color-mix(in srgb, var(--ev) 35%, var(--line)); border-radius: var(--radius-sm); padding: 8px 12px 8px 10px; }
.cal-row:hover { border-color: var(--ev); }
.cal-row.is-past { opacity: .6; }
.cal-row-date { flex: none; width: 40px; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.cal-row-date b { font-family: var(--display); font-size: 22px; font-weight: 600; }
.cal-row-date small { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.cal-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cal-row-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cal-row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.cal-row-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }

/* ───────── Месяц ───────── */
.cal-mbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-mtitle { font-size: 24px; text-transform: uppercase; min-width: 190px; text-align: center; }
.cal-mbar-now { font-size: 13px; color: var(--blue); font-weight: 600; }
.cal-mbar-hint { font-size: 13px; color: var(--muted); }
.cal-grid { border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.cal-wdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--ink); color: var(--paper); }
.cal-wdays span { font: 600 12px var(--display); text-transform: uppercase; letter-spacing: .12em; padding: 7px 8px; }
.cal-wdays span.is-we { color: #A9B4F5; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: 30px repeat(3, 24px) minmax(24px, 1fr); min-height: 124px; row-gap: 2px; }
.cal-week + .cal-week { border-top: 1px solid var(--line); }
.cal-day { border: none; border-left: 1px solid var(--line-2); background: transparent; text-align: left; padding: 6px 8px; cursor: pointer; font: inherit; color: var(--ink); display: flex; align-items: flex-start; }
.cal-day:first-child { border-left: none; }
.cal-day.is-we { background: color-mix(in srgb, var(--paper) 45%, transparent); }
.cal-day.is-out { background: repeating-linear-gradient(135deg, transparent 0 7px, rgba(36,56,200,.05) 7px 8px); color: var(--muted); }
.cal-day:hover { background: var(--blue-soft); }
.cal-dnum { font-family: var(--display); font-size: 15px; font-weight: 600; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.cal-day.is-before:not(.is-out) .cal-dnum { color: var(--muted); }
.cal-day.is-today { box-shadow: inset 0 3px 0 var(--blue); }
.cal-day.is-today .cal-dnum { background: var(--blue); color: #fff; padding: 0 5px; }
.cal-bar { position: relative; z-index: 1; margin: 0 4px; min-width: 0; border: none; border-radius: 5px; padding: 0 8px; font: 600 12px/24px var(--font); text-align: left; cursor: pointer;
  color: #fff; background: var(--ev); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-bar span { display: block; overflow: hidden; text-overflow: ellipsis; }
.cal-bar:hover { filter: brightness(1.12); }
.cal-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-bar.is-past { opacity: .5; }
.cal-more { position: relative; z-index: 1; align-self: start; justify-self: start; margin: 0 6px; border: none; background: none; padding: 2px 4px; font: 600 12px var(--font); color: var(--blue); cursor: pointer; border-radius: 4px; }
.cal-more:hover { background: var(--blue-soft); }
.cal-mlist { display: none; flex-direction: column; gap: 10px; }
.cal-mday { display: flex; flex-direction: column; gap: 6px; }
.cal-mday-head { display: flex; align-items: center; gap: 8px; border-bottom: 1.5px solid var(--ink); padding-bottom: 4px; }
.cal-mday-head b { font-family: var(--display); font-size: 24px; line-height: 1; }
.cal-mday-head span { font-size: 14px; color: var(--ink-2); }
.cal-mday.is-before .cal-mday-head { border-bottom-color: var(--line); }
.cal-mday.is-before .cal-mday-head b { color: var(--muted); }
.cal-mday.is-today .cal-mday-head { border-bottom-color: var(--blue); }
.cal-mday.is-today .cal-mday-head b { color: var(--blue); }
.cal-mday-now { background: var(--blue); color: #fff !important; font: 600 11px var(--display) !important; letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; }
.cal-mcont { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer;
  background: color-mix(in srgb, var(--ev) 6%, transparent); border: 1px solid color-mix(in srgb, var(--ev) 35%, var(--line)); border-radius: var(--radius-sm); padding: 6px 10px; }
.cal-mcont small { flex: none; }
.cal-today-m::before { left: 0; }

/* ───────── Список ───────── */
.cal-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.cal-filters .search { min-width: 240px; }
.cal-count { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.cal-table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.cal-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cal-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1.5px solid var(--ink); background: var(--paper-2); white-space: nowrap; }
.cal-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.cal-table tbody tr:last-child td { border-bottom: none; }
.cal-tr { cursor: pointer; }
.cal-tr:hover td { background: var(--paper-2); }
.cal-tr.is-past td { color: var(--muted); }
.cal-tr.is-past .cal-tag { opacity: .7; }
.cal-tr.is-now td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.cal-td-date { white-space: nowrap; font-weight: 600; }
.cal-td-title { font-weight: 600; min-width: 220px; position: relative; padding-left: 18px !important; }
.cal-td-stripe { position: absolute; left: 6px; top: 10px; bottom: 10px; width: 4px; border-radius: 2px; background: var(--ev); }
.cal-td-none { color: var(--muted); }
.cal-td-num { text-align: right; white-space: nowrap; }
.cal-td-season { white-space: nowrap; }
.cal-sort { display: inline-flex; align-items: center; gap: 4px; border: none; background: none; padding: 0; font: inherit; color: var(--ink); text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.cal-sort-ic { display: inline-flex; transform: rotate(90deg); color: var(--blue); }
.cal-sort-ic.desc { transform: rotate(-90deg); }
.cal-tr-today td { padding: 0 10px; border-bottom: none; position: relative; height: 26px; }
.cal-tr-today td::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--blue); }

/* ───────── Карточка события ───────── */
.cal-modal.modal-wide { max-width: 980px; }
.cal-card { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.cal-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--ev) 9%, var(--card)); border: 1px solid color-mix(in srgb, var(--ev) 40%, transparent); }
.cal-card-when { display: flex; flex-direction: column; }
.cal-card-when b { font-family: var(--display); font-size: 18px; font-weight: 600; text-transform: uppercase; }
.cal-card-when span { font-size: 13px; color: var(--blue); font-weight: 600; }
.cal-card-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; }
.cal-card-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.cal-ws { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--card); }
.cal-ws .btn { width: 100%; }
.cal-ws-empty { font-size: 14px; color: var(--muted); margin: 0; }
.cal-ws-ready { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.cal-ws-ready b { font-family: var(--display); font-size: 18px; color: var(--blue-dk); }
.cal-ws-ready small { font-weight: 400; }
.cal-ws-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.cal-ws-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 10px; margin: 0; font-size: 13px; }
.cal-ws-dl dt { color: var(--muted); }
.cal-ws-dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.cal-over { color: var(--red); }
.cal-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.cal-sw { width: 26px; height: 26px; border-radius: 6px; border: 2px solid var(--card); outline: 1px solid var(--line); background: var(--c); cursor: pointer; padding: 0; }
.cal-sw.on { outline: 2px solid var(--ink); }
.cal-color-field { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
.cal-color-field .field-label { flex: 1 1 100%; }
.field.cal-color-field input[type=color] { width: 56px; flex: none; cursor: pointer; }
.cal-day-list { display: flex; flex-direction: column; gap: 8px; }

/* ───────── Адаптив ───────── */
@media (max-width: 1100px) {
  .cal-theme { grid-template-columns: minmax(0, 1fr); }
  .cal-theme-side { align-items: flex-start; }
  .cal-vectors { justify-content: flex-start; }
  .cal-mbar-hint { display: none; }
}
@media (max-width: 900px) {
  .cal-next-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .cal-next-item { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; border-top-width: 1px; border-color: color-mix(in srgb, var(--ev) 35%, var(--line)); background: color-mix(in srgb, var(--ev) 6%, var(--card)); padding: 8px 10px; }
  .cal-next-item, .cal-next-item:hover { border-top-color: var(--line); }
  .cal-next-item:hover { border-color: var(--ev); }
  .cal-next-rel { flex: none; }
  .cal-next-title { flex: 1 1 60%; }
  .cal-next-sub { flex: 1 1 100%; }
  .cal-card { grid-template-columns: minmax(0, 1fr); }
  .cal-card-side { position: static; order: -1; }
}
@media (max-width: 700px) {
  .cal .page-actions { width: 100%; }
  .cal .page-actions .btn { flex: 1; }
  .cal-tl-month { grid-template-columns: minmax(0, 1fr); }
  .cal-tl-label { flex-direction: row; align-items: baseline; gap: 8px; text-align: left; padding: 14px 0 6px; }
  .cal-tl-label small { margin: 0 0 0 auto; }
  .cal-tl-items { padding-left: 14px; }
  .cal-tl-month + .cal-tl-month .cal-tl-items { border-top: none; }
  .cal-tl-items > .cal-big::before, .cal-tl-items > .cal-row::before { left: -15px; width: 11px; }
  .cal-today::before { left: -22px; }
  .cal-tl .cal-today::after { left: -21px; width: 10px; height: 10px; margin-top: -5px; }
  .cal-tl-month.is-empty .cal-tl-items { padding-left: 14px; }
  .cal-theme { padding: 14px; }
  .cal-theme-title { font-size: 24px; }
  .cal-theme-stats { gap: 18px; }
  .cal-big { padding: 12px; }
  .cal-big-title { font-size: 19px; }
  .cal-big-actions .btn { flex: 1; }
  .cal-row { flex-wrap: wrap; gap: 4px 10px; }
  .cal-row-main { flex: 1 1 calc(100% - 60px); }
  .cal-row-tags { flex: 1 1 100%; justify-content: flex-start; padding-left: 50px; }
  .cal-grid { display: none; }
  .cal-mlist { display: flex; }
  .cal-mtitle { font-size: 20px; min-width: 0; flex: 1; white-space: nowrap; }
  .cal-mbar-now { display: none; }
  .cal-filters .search-wrap { flex: 1 1 100%; }
  .cal-filters .search { min-width: 0; width: 100%; }
  .cal-filters select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .cal-filters .grow { display: none; }
  .cal-table-wrap { border: none; background: transparent; overflow: visible; }
  .cal-table thead { display: none; }
  .cal-table, .cal-table tbody, .cal-table tr, .cal-table td { display: block; width: 100%; }
  .cal-tr { background: color-mix(in srgb, var(--ev) 6%, var(--card)); border: 1px solid color-mix(in srgb, var(--ev) 35%, var(--line)); border-radius: var(--radius-sm); margin-bottom: 8px; padding: 8px 10px; }
  .cal-tr:hover td { background: transparent; }
  .cal-tr.is-past { opacity: .7; }
  .cal-table td { border: none; padding: 1px 0; display: flex; gap: 8px; align-items: baseline; }
  .cal-table td::before { content: attr(data-label); flex: 0 0 104px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .cal-table .cal-td-title { min-width: 0; padding-left: 0 !important; font-size: 16px; order: -1; }
  .cal-table .cal-td-title::before, .cal-table .cal-td-date::before { display: none; }
  .cal-td-stripe { display: none; }
  .cal-td-num { text-align: left; }
  .cal-table .cal-td-none { display: none; }
  .cal-tr { display: flex !important; flex-direction: column; }
  .cal-tr-today td { display: block; height: 26px; margin-bottom: 8px; }
  .cal-tr-today td::before { content: ''; flex: none; }
  .cal-mlist .cal-today::before { left: 0; }
}
