/* CronCalc — "midnight ops" dark theme.
   Cool slate surfaces, orange primary (#ff7847) + ice-blue accent (#8dd6ff)
   from site.config.json. Declared in both modes so the palette is identical
   regardless of prefers-color-scheme and load order. */

:root {
  --bg: #0d1117;
  --surface: #131a23;
  --surface-2: #1a2430;
  --text: #e8eef5;
  --text-dim: #93a3b5;
  --border: #2b3a4c;
  --cc-ok: #7dd68f;
  --cc-warn: #ffcf6e;
  --cc-bad: #ff7d6e;
  --cc-info: #8dd6ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #131a23;
    --surface-2: #1a2430;
    --text: #e8eef5;
    --text-dim: #93a3b5;
    --border: #2b3a4c;
  }
}
html {
  color-scheme: dark;
}

/* ---------- calculator shell ---------- */
.cc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.1rem 1.1rem 1rem;
  margin: 1.4rem 0 1.8rem;
  box-shadow: 0 10px 34px -20px rgba(0, 0, 0, 0.75);
}
@media (min-width: 54rem) {
  .prose .cc {
    width: min(64rem, calc(100vw - 2.5rem));
  }
}

/* ---------- expression input ---------- */
.cc-top {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}
.cc-fieldwrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 auto;
  min-width: 0;
}
.cc-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.cc-label i {
  font-style: normal;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.02em;
  margin-left: 0.4rem;
}
#cc-expr {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#cc-expr:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
#cc-expr.invalid {
  border-color: var(--cc-bad);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cc-bad) 18%, transparent);
}

/* ---------- description + note chips ---------- */
.cc-desc {
  margin: 0.9rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  min-height: 1.5em;
}
.cc-desc::before {
  content: '→ ';
  color: var(--accent);
}
.cc-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
.cc-notes:empty { margin-top: 0; }
.cc-chip {
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.45;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--surface-2);
}
.cc-chip.info { color: var(--cc-info); border-color: color-mix(in srgb, var(--cc-info) 45%, var(--border)); }
.cc-chip.warn { color: var(--cc-warn); border-color: color-mix(in srgb, var(--cc-warn) 45%, var(--border)); }
.cc-chip.bad  { color: var(--cc-bad);  border-color: color-mix(in srgb, var(--cc-bad) 50%, var(--border)); }

/* ---------- error panel ---------- */
.cc-err {
  margin-top: 0.9rem;
  border: 1px solid color-mix(in srgb, var(--cc-bad) 55%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--cc-bad) 8%, var(--bg));
  padding: 0.65rem 0.85rem;
}
.cc-err p {
  margin: 0 0 0.45rem;
  color: var(--cc-bad);
  font-size: 0.9rem;
  font-weight: 600;
}
.cc-err pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
.cc-reboot {
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
  color: var(--cc-info);
  border-left: 3px solid var(--cc-info);
  padding-left: 0.7rem;
}

/* ---------- next runs ---------- */
.cc-panel {
  margin-top: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem 0.6rem;
}
.cc-panelhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.cc-countwrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.cc-runs {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
}
.cc-runs li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.34rem 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--border) 60%, transparent);
}
.cc-runs li:last-child { border-bottom: none; }
.cc-runs li::before {
  content: '▸';
  color: var(--primary);
  margin-right: 0.5rem;
}
.cc-runs time { color: var(--text); flex: 1 1 auto; }
.cc-runs em {
  font-style: normal;
  color: var(--text-dim);
  font-size: 0.8rem;
  white-space: nowrap;
}
.cc-runs .cc-never {
  color: var(--cc-bad);
  font-family: inherit;
}
.cc-runs .cc-never::before { content: '✕'; color: var(--cc-bad); }
.cc-tz {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-dim);
}

/* ---------- builder ---------- */
.cc-builder {
  margin-top: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0.75rem 0.85rem 0.65rem;
}
.cc-builder h2, .cc-presets h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.55rem;
}
.cc-field {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  align-items: start;
  gap: 0.55rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--border) 55%, transparent);
}
.cc-field:last-of-type { border-bottom: none; }
.cc-fname {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  padding-top: 0.45rem;
}
.cc-ctrl {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}
.cc-inputs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}
.cc-inputs code { font-size: 0.95rem; }
.cc-ctrl select, .cc-inputs select {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
}
.cc-inputs input[type="number"], .cc-inputs input[type="text"], .cc-inputs input:not([type]) {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  width: 4.2rem;
  box-sizing: border-box;
}
.cc-inputs input[type="text"] { width: 11rem; }
.cc-inputs input:focus {
  outline: none;
  border-color: var(--primary);
}
.cc-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.cc-chipbox {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  user-select: none;
}
.cc-chipbox input { accent-color: var(--primary); margin: 0; }
.cc-chipbox:has(input:checked) {
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
  background: color-mix(in srgb, var(--primary) 14%, var(--bg));
}
.cc-bnote {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-dim);
}

/* ---------- buttons ---------- */
.cc-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, filter 0.15s;
}
.cc-btn:hover { border-color: color-mix(in srgb, var(--primary) 60%, var(--border)); }
.cc-btn.sm { font-size: 0.75rem; padding: 0.3rem 0.7rem; }

/* ---------- presets table ---------- */
.cc-presets { margin-top: 1.2rem; }
.cc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.cc-table th, .cc-table td {
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
}
.cc-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}
.cc-table td { color: var(--text); }
.cc-table td:nth-child(2) { color: var(--text-dim); }
.cc-table code { white-space: nowrap; }
.cc-table button {
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--primary);
  cursor: pointer;
}
.cc-table button:hover { border-color: var(--primary); }
.cc-table tr:last-child td { border-bottom: none; }

/* ---------- article polish ---------- */
.prose pre { background: var(--bg); border: 1px solid var(--border); }
.prose code { background: var(--surface-2); }
.prose pre code { background: none; }
.prose table code { white-space: nowrap; }

@media (max-width: 480px) {
  .cc { padding: 0.8rem; }
  .cc-top { flex-direction: column; align-items: stretch; }
  #cc-expr { font-size: 1.05rem; min-height: 2.5rem; }
  .cc-btn, .cc-btn.sm { min-height: 2.5rem; }
  .cc-field { grid-template-columns: 1fr; gap: 0.3rem; }
  .cc-fname { padding-top: 0; }
  .cc-ctrl select, .cc-inputs select,
  .cc-inputs input[type="number"], .cc-inputs input[type="text"],
  .cc-table button { min-height: 2.5rem; }
  .cc-chipbox { min-height: 2.2rem; }
  .cc-runs li { flex-direction: column; gap: 0.1rem; }
  .cc-runs em { white-space: normal; }
}
