/* WordClock WebApp — stylesheet */

:root {
  --bg:      #0b0b0b;
  --panel:   #111111;
  --panel-2: #161616;
  --line:    #262626;
  --text:    #f2f2f2;
  --muted:   #8a8a8a;
  --accent:  #d9ff3d;
  --bad:     #ff5a4a;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.02), transparent 32%),
    repeating-linear-gradient(0deg,
      transparent 0 27px,
      rgba(255,255,255,.018) 27px 28px);
}

button, input { font: inherit; }
button, input { appearance: none; border-radius: 0; }
button { cursor: pointer; background: none; color: inherit; border: 1px solid var(--line); }
input  { border: 1px solid var(--line); background: var(--panel); color: var(--text); }
p      { margin: 0; }

/* ── Screen reader only ─────────────────────────────────── */
.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  border: 0; overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── App shell ──────────────────────────────────────────── */
.app  { width: min(100%, 560px); margin: 0 auto; padding: 0 18px 28px; }
.screen        { display: block; }
.screen[hidden] { display: none; }

/* ── Header ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 18px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 24px; font-weight: 700; letter-spacing: .14em; }

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  background: var(--panel);
  font-size: 18px;
}

.indicator {
  width: 12px; height: 12px;
  border: 1px solid var(--line);
  background: var(--bad);
  flex-shrink: 0;
  transition: background-color .16s ease, border-color .16s ease;
}
.indicator.live {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Layout helpers ─────────────────────────────────────── */
.panel { background: rgba(17,17,17,.94); border: 1px solid var(--line); padding: 16px; }
.stack { display: grid; gap: 14px; }

/* ── Toggles ────────────────────────────────────────────── */
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toggle {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  text-align: left;
}
.toggle span {
  font-family: "IBM Plex Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.toggle strong {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: .08em;
  color: var(--muted);
}
.toggle.on              { border-color: var(--accent); }
.toggle.on strong       { color: var(--accent); }

/* ── Brightness slider ──────────────────────────────────── */
.range-block { display: grid; gap: 12px; }
.range-head  {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.range-head strong { font-size: 14px; letter-spacing: .1em; }
.range-head span {
  font-family: "IBM Plex Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--muted);
}

input[type=range] { width: 100%; height: 22px; background: transparent; border: none; padding: 0; }
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(90deg,
    var(--accent) 0,
    var(--accent) var(--fill, 0%),
    var(--line)   var(--fill, 0%),
    var(--line)   100%);
}
input[type=range]::-moz-range-track { height: 4px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -9px;
  background: var(--text); border: 1px solid var(--bg);
}
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--text); border: 1px solid var(--bg);
}

/* ── Presets section ────────────────────────────────────── */
.presets-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.presets-head strong { font-size: 14px; letter-spacing: .12em; }

.add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: var(--panel);
  font-size: 26px;
  line-height: 1;
}

.empty {
  padding: 16px;
  background: var(--panel);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.preset-list { display: grid; gap: 10px; }
.preset-row  { display: grid; grid-template-columns: 1fr; gap: 10px; position: relative; }

.preset-apply { background: var(--panel); padding: 14px; text-align: left; }
.preset-apply strong {
  display: block;
  font-size: 15px; font-weight: 600; letter-spacing: .04em;
}
.preset-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-family: "IBM Plex Mono", Menlo, monospace;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
.preset-swatch {
  display: block;
  width: 100%; height: 8px;
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(90deg,
    var(--rgb,   #000) 0 74%,
    var(--white, #000) 74% 100%);
}
.preset-edit-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  color: var(--bg);
  border: none;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: opacity .16s ease;
}
.preset-edit-icon:hover {
  opacity: 0.8;
}

/* ── Editor screen ──────────────────────────────────────── */
.editor-shell { min-height: 100dvh; }
.editor-panel { display: grid; gap: 16px; padding-bottom: 28px; }

.field { display: grid; gap: 8px; }
.field span,
.helper-note,
.tuple {
  font-family: "IBM Plex Mono", Menlo, monospace;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.editor-copy {
  font-size: 14px; line-height: 1.45;
  color: var(--muted);
}

.name-input,
.num { min-height: 52px; padding: 0 14px; font-size: 18px; }

.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tuple { padding: 12px 14px; border: 1px solid var(--line); background: var(--panel); }

.helper-toggle,
.action {
  min-height: 50px;
  padding: 0 14px;
  background: var(--panel-2);
}
.helper-toggle.open { border-color: var(--accent); color: var(--accent); }

.helper { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); background: var(--panel); }
.helper[hidden] { display: none; }
input[type=color] { width: 100%; height: 52px; padding: 6px; border: none; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action.primary { border-color: var(--accent); color: var(--accent); }
.action.warn    { border-color: var(--bad);    color: var(--bad);    }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 460px) {
  .app      { padding: 0 14px 22px; }
  .brand    { font-size: 21px; }
  .grid4,
  .actions { grid-template-columns: 1fr; }
}
