/* Chowaniec theme layer (see /theme.js). Colours come from CSS variables that theme.js sets on <html>;
   this file maps the pages' utility classes onto them and adds the shared motion polish. */

/* ---------- page background ---------- */
html[data-look] { background: var(--bg); }
html[data-look] body { background: var(--page-bg); background-color: var(--bg); background-attachment: fixed; color: var(--text); }
html[data-look] ::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
html[data-look] { accent-color: var(--accent); }
html[data-look] ::placeholder { color: var(--faint); opacity: 1; }
html[data-look] ::-webkit-scrollbar-thumb { background: var(--line-strong); }

/* ---------- Tailwind colour classes → theme tokens ---------- */
html[data-look] .text-black, html[data-look] .text-gray-900, html[data-look] .text-gray-800, html[data-look] .group:hover .group-hover\:text-black, html[data-look] .hover\:text-black:hover { color: var(--text); }
html[data-look] .text-gray-700, html[data-look] .text-gray-600 { color: var(--text-2); }
html[data-look] .text-gray-500 { color: var(--muted); }
html[data-look] .text-gray-400, html[data-look] .text-gray-300 { color: var(--faint); }
html[data-look] .marker\:text-gray-300 *::marker, html[data-look] .marker\:text-gray-400 *::marker, html[data-look] .marker\:text-gray-300::marker, html[data-look] .marker\:text-gray-400::marker { color: var(--faint); }
html[data-look] .text-red-600, html[data-look] .text-red-500, html[data-look] .hover\:text-red-600:hover { color: var(--danger); }
html[data-look] .text-amber-600 { color: var(--warn-fg); }

html[data-look] .bg-white { background-color: var(--surface); }
html[data-look] .bg-white\/80 { background-color: color-mix(in srgb, var(--surface) 80%, transparent); }
html[data-look] .bg-gray-50, html[data-look] .hover\:bg-gray-50:hover { background-color: var(--surface-2); }
html[data-look] .bg-gray-100, html[data-look] .bg-gray-200, html[data-look] .hover\:bg-gray-100:hover { background-color: var(--surface-3); }
html[data-look] .hover\:bg-white:hover, html[data-look] .focus\:bg-white:focus { background-color: var(--surface); }
html[data-look] .disabled\:bg-gray-200:disabled { background-color: var(--surface-3); }
html[data-look] .disabled\:text-gray-400:disabled { color: var(--faint); }
html[data-look] .bg-amber-50 { background-color: var(--warn-bg); }
html[data-look] .border-amber-100 { border-color: var(--warn-line); }
html[data-look] .hover\:bg-red-50:hover { background-color: var(--danger-bg); }
html[data-look] .border-red-200 { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* primary buttons: black in Classic, the theme's accent everywhere else */
html[data-look] .bg-black, html[data-look] .hover\:bg-black:hover { background-color: var(--accent); }
html[data-look] .bg-black.text-white, html[data-look] .bg-black .text-white, html[data-look] .hover\:text-white:hover { color: var(--accent-ink); }
html[data-look] .hover\:bg-gray-800:hover { background-color: color-mix(in srgb, var(--accent) 86%, var(--bg)); }

html[data-look] .border-gray-100, html[data-look] .divide-gray-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--line); }
html[data-look] .border-gray-200, html[data-look] .border-gray-200\/60, html[data-look] .hover\:border-gray-300:hover { border-color: var(--line-strong); }
html[data-look] .focus\:border-black:focus, html[data-look] .hover\:border-black:hover, html[data-look] .focus-within\:border-black:focus-within { border-color: var(--text); }
html[data-look] .accent-black { accent-color: var(--accent); }
html[data-look] .selection\:bg-gray-200 *::selection, html[data-look] .selection\:bg-gray-200::selection { background: var(--surface-3); }

/* ---------- Meet: its dark greys follow the theme ---------- */
html[data-look] .bg-\[\#18191b\] { background-color: var(--bg); }
html[data-look] .bg-\[\#1e1f22\], html[data-look] .bg-\[\#202124\] { background-color: var(--surface); }
html[data-look] .bg-\[\#282a2d\] { background-color: var(--surface-2); }
html[data-look] .bg-\[\#3c4043\] { background-color: var(--surface-3); }
html[data-look] .bg-\[\#474a4d\] { background-color: color-mix(in srgb, var(--surface-3) 80%, var(--text)); }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  html[data-motion="full"] body { animation: cz-page-in .38s ease-out backwards; }
  html[data-motion="full"] :where(button, a, input, select, textarea, summary, [role="button"], .btn, .card, .seg button, .tile, .hit, .dm-row, .day) {
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, box-shadow .25s ease, transform .2s cubic-bezier(.34, 1.4, .5, 1), opacity .2s ease;
  }
  html[data-motion="full"] :where(button:not(:disabled), .btn, [role="button"], a.hit, .tile, .ctp-tile):active { transform: scale(.965); transition-duration: .08s; }
  html[data-motion="full"] :where(.card, .hit):hover { box-shadow: 0 8px 26px -14px rgba(0, 0, 0, .35); }
  html[data-motion="full"] .pop:not(.hidden):not(.sheet-enter), html[data-motion="full"] [role="dialog"]:not(.hidden):not(.sheet-enter):not(#sheet) { animation: cz-pop .22s cubic-bezier(.34, 1.3, .5, 1) both; transform-origin: bottom center; }
  html[data-motion="full"] .cz-enter .bubble { animation: cz-bubble .38s cubic-bezier(.34, 1.4, .5, 1) both; }
  html[data-motion="full"] .cz-enter.mine .bubble { transform-origin: bottom right; }
  html[data-motion="full"] .cz-enter.theirs .bubble { transform-origin: bottom left; }
  html[data-motion="full"] #toast:not(.hidden), html[data-motion="full"] .toast { animation: cz-toast .32s cubic-bezier(.34, 1.3, .5, 1) both; }
  html.cz-fade, html.cz-fade *, html.cz-fade *::before, html.cz-fade *::after { transition: background-color .4s ease, color .4s ease, border-color .4s ease, fill .4s ease, box-shadow .4s ease !important; }
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
@keyframes cz-page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cz-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cz-bubble { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes cz-toast { from { opacity: 0; margin-top: 10px; } to { opacity: 1; margin-top: 0; } }

/* ---------- seasonal decorations (see /theme-fx.js) ---------- */
#cz-fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
#cz-fx canvas { position: absolute; inset: 0; }
#cz-fx .cz-web { position: absolute; width: min(34vw, 150px); aspect-ratio: 1; color: rgba(160, 150, 190, .5); }
#cz-fx.dark .cz-web { color: rgba(220, 210, 255, .35); }
#cz-fx .cz-web.tl { top: 0; left: 0; }
#cz-fx .cz-web.tr { top: 0; right: 0; transform: scaleX(-1); }
#cz-fx .cz-lights { position: absolute; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 22px; color: rgba(110, 110, 110, .6); }
#cz-fx .cz-lights .cz-wire { position: absolute; inset: 0; width: 100%; height: 12px; }
#cz-fx .cz-lights i { position: absolute; width: 7px; height: 9px; margin-left: -3px; border-radius: 50% 50% 55% 55%; background: var(--c); box-shadow: 0 0 9px 2px var(--c); animation: cz-twinkle 1.8s ease-in-out infinite; }
#cz-fx.still .cz-lights i { animation: none; }
@keyframes cz-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media print { #cz-fx { display: none; } }

/* ---------- theme picker ---------- */
.ctp { display: grid; gap: 18px; color: var(--text); font-family: 'Outfit', system-ui, sans-serif; }
.ctp-block { display: grid; gap: 10px; }
.ctp-h { font: 500 12px/1 'JetBrains Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ctp-s { font-size: 13px; color: var(--muted); line-height: 1.4; }
.ctp-t { font-size: 15px; font-weight: 500; }
.ctp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.ctp-tile { display: grid; gap: 6px; padding: 8px; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 16px; cursor: pointer; min-height: 44px; }
.ctp-tile:hover { border-color: var(--line-strong); }
.ctp-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ctp-tile:focus-visible, .ctp-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctp-sw { display: flex; height: 38px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.ctp-sw i { flex: 1; display: block; }
.ctp-sw i:nth-child(1) { flex: 2; }
.ctp-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.ctp-sub { font-size: 11px; color: var(--muted); margin-top: -4px; }
.ctp-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); justify-self: start; }
.ctp-seg button { font: inherit; font-size: 14px; font-weight: 500; min-height: 40px; padding: 0 16px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; }
.ctp-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
.ctp-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.ctp-grow { flex: 1; min-width: 0; }
.ctp-select { font: inherit; font-size: 15px; min-height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); max-width: 46%; }
.ctp-custom { display: grid; gap: 10px; padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.ctp-color { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 15px; }
.ctp-color input[type="color"] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
.ctp-switch { position: relative; width: 52px; height: 32px; flex: none; }
.ctp-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.ctp-track { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .2s; }
.ctp-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .25s cubic-bezier(.34, 1.4, .5, 1); }
.ctp-switch input:checked + .ctp-track { background: var(--accent); }
.ctp-switch input:checked + .ctp-track::after { transform: translateX(20px); }
.ctp-switch input:focus-visible + .ctp-track { outline: 2px solid var(--accent); outline-offset: 2px; }
