/* Customize page (js/customize.js) + the rules that make the saved look show up. Load AFTER refine.css. */

/* ---------- the look itself (only active once something was customized: <html data-tn>) ---------- */
html[data-tn] { background: var(--rf-bg); }
html[data-tn] body { background: transparent !important; }
/* pages shown inside a frame (Web Grind, Compare) stay transparent so the site background shows through them */
html[data-tn-frame] { background: transparent !important; }
html[data-tn-frame] body { zoom: var(--tn-zoom, 1); }
#tnBg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; display: none; }
#tnBg .tnbg-fill, #tnBg .tnbg-dim { position: absolute; inset: 0; }
html[data-tn-bg="layer"] #tnBg { display: block; }
html[data-tn-bg="layer"] .topbar, html[data-tn-bg="layer"] .sidebar { background: var(--tn-bar) !important; }

html[data-tn] ::selection { background: var(--tn-accent); color: var(--tn-accent-ink); }
html[data-tn] { accent-color: var(--tn-accent); }
html[data-tn] .nav-indicator { background: transparent !important; }
html[data-tn] .nav-indicator::before { background: var(--tn-accent) !important; }
html[data-tn] .nav-btn.active { color: var(--tn-accent) !important; }
html[data-tn] .dash-btn.solid, html[data-tn] .hm-btn.primary, html[data-tn] .cz-seg button.on, html[data-tn] .cz-btn.solid {
  background: var(--tn-accent) !important; border-color: var(--tn-accent) !important; color: var(--tn-accent-ink) !important;
}
html[data-tn] .pf-input:focus, html[data-tn] .rename-input:focus, html[data-tn] .search-bar:focus, html[data-tn] .auth-form input:focus { border-color: var(--tn-accent) !important; }

html[data-tn-font] body,
html[data-tn-font] :is(h1, h2, h3, h4, p, span, div, a, button, input, select, textarea, li, td, th, label, summary, small, b, strong):not(.zodo):not(.zodo *):not(.odometer *) {
  font-family: var(--tn-font) !important;
}
html[data-tn] .content { zoom: var(--tn-zoom, 1); }
html[data-tn-snow="off"] #snowfall { display: none !important; }
/* over a picture, panels and bars stay mostly solid so text and buttons are always easy to read */
html[data-tn-img] .topbar, html[data-tn-img] .sidebar { background: rgba(8,8,10,.82) !important; }
html[data-tn-motion="off"] *, html[data-tn-motion="off"] *::before, html[data-tn-motion="off"] *::after {
  animation: none !important; scroll-behavior: auto !important;
}

/* ---------- the page ---------- */
.cz-view { width: min(1100px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 64px; }
.cz-view[hidden] { display: none !important; }
.cz-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; margin-top: 22px; align-items: start; }
.cz-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--rf-surface); border: 1px solid var(--rf-line); border-radius: var(--rf-r-lg); }
.cz-nav button { display: block; width: 100%; padding: 11px 12px; border: 0; border-radius: var(--rf-r); background: transparent; text-align: left; cursor: pointer; font-family: 'Inter', system-ui, sans-serif; }
.cz-nav button b { display: block; font-size: 14px; font-weight: 600; color: #d4d4d8; }
.cz-nav button span { display: block; margin-top: 3px; font-size: 12px; color: #71717a; }
.cz-nav button:hover { background: var(--rf-surface-2); }
.cz-nav button.on { background: var(--rf-surface-2); box-shadow: inset 3px 0 0 var(--tn-accent, #fafafa); }
.cz-nav button.on b { color: #fafafa; }
.cz-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cz-login { max-width: 520px; margin: 28px auto 0; text-align: center; }
.cz-login .cz-btn { margin-top: 4px; }
.cz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 22px; align-items: start; }
.cz-card { padding: 22px 24px; min-width: 0; background: var(--rf-surface) !important; border: 1px solid var(--rf-line) !important; border-radius: var(--rf-r-lg) !important; }
.cz-card.wide { grid-column: 1 / -1; }
.cz-card h2 { margin: 0 0 4px; font: 600 16px/1.2 'Inter', system-ui, sans-serif; color: #fafafa; }
.cz-card > p { margin: 0 0 16px; color: #8f8f98; font-size: 13px; line-height: 1.5; }
.cz-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--rf-line); }
.cz-row:first-of-type { border-top: 0; }
.cz-row > label, .cz-lab { font-size: 13px; color: #d4d4d8; font-weight: 500; }
.cz-row small { display: block; margin-top: 2px; color: #71717a; font-size: 12px; font-weight: 400; }
.cz-field { margin-top: 14px; }
.cz-field:first-child { margin-top: 0; }
.cz-field > .cz-lab { display: flex; justify-content: space-between; margin-bottom: 8px; }
.cz-field > .cz-lab span { color: #8f8f98; font-variant-numeric: tabular-nums; }

.cz-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.cz-theme { position: relative; padding: 0; border: 1px solid var(--rf-line); border-radius: var(--rf-r-lg); background: var(--rf-surface-2); color: #d4d4d8; cursor: pointer; overflow: hidden; text-align: left; font: 500 12px/1 'Inter', system-ui, sans-serif; }
.cz-theme:hover { border-color: var(--rf-line-hi); }
.cz-theme.on { border-color: var(--tn-accent, #fafafa); box-shadow: 0 0 0 1px var(--tn-accent, #fafafa); }
.cz-theme i { display: block; height: 52px; }
.cz-theme span { display: block; padding: 9px 10px; }

.cz-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--rf-line); border-radius: var(--rf-r); background: var(--rf-surface-2); }
.cz-seg button { height: 32px; padding: 0 13px; border: 0; border-radius: calc(var(--rf-r) - 2px); background: transparent; color: #a1a1aa; font: 500 13px/1 'Inter', system-ui, sans-serif; cursor: pointer; }
.cz-seg button:hover { color: #fafafa; }
.cz-seg button.on { background: #fafafa; color: #0b0b0c; }

.cz-range { width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer; }
.cz-color { display: flex; align-items: center; gap: 10px; }
.cz-color input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--rf-line); border-radius: var(--rf-r); background: var(--rf-surface-2); cursor: pointer; }
.cz-color code { color: #a1a1aa; font-size: 12px; }
.cz-sw { display: flex; flex-wrap: wrap; gap: 8px; }
.cz-sw button { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.cz-sw button.on { border-color: #fafafa; box-shadow: 0 0 0 2px var(--rf-bg), inset 0 0 0 1px rgba(255,255,255,.2); }

.cz-text { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--rf-line); border-radius: var(--rf-r); background: var(--rf-surface-2); color: #fafafa; font: 400 13px 'Inter', system-ui, sans-serif; }
.cz-text:focus { outline: none; border-color: var(--tn-accent, var(--rf-line-hi)); }
.cz-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cz-btn { height: 38px; padding: 0 16px; border: 1px solid var(--rf-line-hi); border-radius: var(--rf-r); background: var(--rf-surface-2); color: #fafafa; font: 600 13px/1 'Inter', system-ui, sans-serif; cursor: pointer; }
.cz-btn:hover { background: var(--rf-line); }
.cz-btn.solid { background: #fafafa; border-color: #fafafa; color: #0b0b0c; }
.cz-btn.danger:hover { color: #f87171; border-color: #f87171; }
.cz-note { margin: 10px 0 0; color: #8f8f98; font-size: 12px; line-height: 1.5; }
.cz-note.err { color: #f87171; }
.cz-colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 22px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rf-line); }
.cz-colors > h3 { grid-column: 1 / -1; margin: 0; font: 600 13px/1 'Inter', system-ui, sans-serif; color: #d4d4d8; }
.cz-colors .cz-field { margin: 0; }
.cz-imgprev { width: 100%; height: 110px; margin-top: 12px; border: 1px solid var(--rf-line); border-radius: var(--rf-r); background: #000 center / cover no-repeat; }

.cz-sw2 { position: relative; width: 44px; height: 24px; flex: none; }
.cz-sw2 input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.cz-sw2 i { position: absolute; inset: 0; border-radius: 999px; background: var(--rf-line-hi); transition: background .15s; }
.cz-sw2 i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fafafa; transition: transform .15s; }
.cz-sw2 input:checked + i { background: var(--tn-accent, #4ee08a); }
.cz-sw2 input:checked + i::after { transform: translateX(20px); background: var(--tn-accent-ink, #0b0b0c); }
.cz-sw2 input:focus-visible + i { outline: 2px solid #fafafa; outline-offset: 2px; }

@media (max-width: 800px) {
  .cz-view { width: calc(100% - 32px); padding-top: 20px; }
  .cz-grid { grid-template-columns: 1fr; }
  .cz-shell { grid-template-columns: 1fr; gap: 14px; }
  .cz-nav { position: static; flex-direction: row; overflow-x: auto; padding: 6px; }
  .cz-nav button { flex: none; width: auto; padding: 9px 14px; white-space: nowrap; }
  .cz-nav button span { display: none; }
  .cz-nav button.on { box-shadow: inset 0 -3px 0 var(--tn-accent, #fafafa); }
  .cz-card { padding: 18px; }
  .cz-row { flex-wrap: wrap; }
  .cz-text, .cz-btn { min-height: 44px; font-size: 16px; }
}

/* main buttons inside the framed pages (Web Grind, Compare) follow the accent colour too */
html[data-tn-frame] .search-button, html[data-tn-frame] .button:not(:disabled) {
  background: var(--tn-accent) !important; border-color: var(--tn-accent) !important; color: var(--tn-accent-ink) !important;
}

/* ---------- glass transparency effect (Customize > Glass effect; <html data-tn-glass>) ----------
   customize-boot.js makes --rf-surface / --rf-surface-2 see-through and sets the blur and edge colours.
   refine.css turns every backdrop blur off with *{...!important}; these more specific rules turn it back on here only. */
html[data-tn-glass] :is(.hm-glass, .up-panel, .up-patch, .pick-card, .grind-panel, .ch-card, .dash-card, .pf-card, .pf-modal, .profile-menu,
  .glass-card, .cmp-card, .live-window, .soc-card, .dg-card, .dg-dd-list, .collab-list, .login-bubble, .gw-row, .status-card, .cr-card,
  .panel, .card, .hm-fact, .claim-box, .check-box, .commands-column, .collab-column, .up-list li, .hm-card,
  .search, .discord-btn, .hm-btn.ghost, .live-btn, .search-container, .ch-search, .pf-input, .rename-input, .search-bar, .auth-form input,
  .command-grid > *, .command-grid button, .collab-row, .ct-search, .ct-chip, .ct-list, .rc-card, .race-panel, .race-empty,
  .dg-race-btn, .race-btn:not(.solid), .race-select, .race-seg, .cz-card, .cz-nav, .cz-text) {
  -webkit-backdrop-filter: blur(var(--tn-glass-blur, 12px)) saturate(140%) !important;
  backdrop-filter: blur(var(--tn-glass-blur, 12px)) saturate(140%) !important;
  border-color: var(--tn-glass-line) !important;
  box-shadow: inset 0 1px 0 var(--tn-glass-hi) !important;
}
html[data-tn-glass] :is(.command-grid button, .hm-card, .ch-card, .ct-chip, .search, .discord-btn, .hm-btn.ghost):hover {
  background: var(--rf-surface-2) !important; border-color: rgba(255,255,255,.28) !important;
}
html[data-tn-glass] .topbar, html[data-tn-glass] .sidebar {
  background: var(--tn-bar) !important; border-color: var(--tn-glass-line) !important;
  -webkit-backdrop-filter: blur(var(--tn-glass-blur, 12px)) saturate(140%) !important;
  backdrop-filter: blur(var(--tn-glass-blur, 12px)) saturate(140%) !important;
}
/* labels under the Transparency slider */
.cz-ticks { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin: 6px 0 14px; font-size: 11px; color: #71717a; }
.cz-ticks span:last-child { text-align: right; }
