/* =============================================================================
   app.css — design layer on top of Bootstrap 5.3 (dark mode).
   Bootstrap supplies grid, forms and buttons; everything below is the identity:
   an indigo-slate console with a six-column "cron ruler" as the centrepiece.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  --ink-900: #0c1120;   /* page */
  --ink-800: #131a2b;   /* panel */
  --ink-700: #1a2337;   /* raised element */
  --ink-600: #232e47;   /* hover */
  --line:    #2a3550;
  --line-soft: #202a41;

  --text:    #e2e7f3;
  --muted:   #8e9ab8;
  --faint:   #63709010;

  --sprout:  #85c94f;   /* valid state, scheduled runs */
  --sprout-dim: #85c94f22;
  --beam:    #9a97ff;   /* the field currently being edited */
  --beam-dim: #9a97ff1f;
  --amber:   #f2b544;
  --rose:    #ff7a7a;

  --radius:  14px;
  --radius-sm: 9px;

  --font-display: "Space Grotesk", "Segoe UI Semibold", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

/* Bootstrap overrides, kept to the few variables that carry the theme. */
[data-bs-theme="dark"] {
  --bs-body-bg: var(--ink-900);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
  --bs-emphasis-color: #fff;
  --bs-link-color: var(--beam);
  --bs-link-hover-color: #b9b7ff;
  --bs-focus-ring-color: rgba(154, 151, 255, .45);
}

/* --- Base ----------------------------------------------------------------- */
body {
  font-family: var(--font-body);
  background:
    radial-gradient(900px 480px at 88% 0%, rgba(133, 201, 79, .07) 0%, transparent 55%),
    radial-gradient(1200px 600px at 50% -20%, rgba(154, 151, 255, .10) 0%, transparent 60%),
    var(--ink-900);
  background-attachment: fixed;
  font-size: .96rem;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, .display-face {
  font-family: var(--font-display);
  letter-spacing: -.02em;
}

code, kbd, pre, .mono { font-family: var(--font-mono); }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--beam);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Small uppercase caption used for every panel and field label. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Shell ---------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 17, 32, .72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand__mark { color: var(--sprout); flex: none; }
.brand__accent { color: var(--muted); font-weight: 500; }

.site-footer {
  border-top: 1px solid var(--line-soft);
  background: #0a0e1a;
  color: var(--muted);
  font-size: .88rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* --- Panels --------------------------------------------------------------- */
.panel {
  background: var(--ink-800);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .95rem 1.15rem;
  border-bottom: 1px solid var(--line-soft);
}
.panel__body { padding: 1.15rem; }

/* --- Hero: the cron ruler ------------------------------------------------- */
.hero { padding: clamp(2rem, 6vw, 3.75rem) 0 1.5rem; }

.hero__kicker { margin-bottom: .85rem; }

.hero__title {
  font-size: clamp(1.75rem, 4.2vw, 2.6rem);
  font-weight: 700;
  margin-bottom: .6rem;
}
.hero__title em {
  font-style: normal;
  color: var(--sprout);
}

.hero__lede {
  color: var(--muted);
  max-width: 46ch;
  margin-bottom: 1.75rem;
}

.ruler {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.ruler__field {
  background: var(--ink-800);
  border: 0;
  padding: .8rem .5rem 1rem;
  text-align: center;
  color: var(--text);
  cursor: pointer;
  transition: background .18s ease, box-shadow .18s ease;
  min-width: 0;
}
.ruler__field:hover,
.ruler__field:focus-visible { background: var(--ink-700); }

.ruler__field[data-active="true"] {
  background: var(--beam-dim);
  box-shadow: inset 0 -2px 0 var(--beam);
}

.ruler__label {
  display: block;
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ruler__token {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(.95rem, 2.4vw, 1.45rem);
  font-weight: 700;
  color: #fff;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.ruler[data-state="invalid"] .ruler__token { color: var(--rose); }

/* Status line under the ruler: the sentence plus validity. */
.readout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .65rem;
  margin-top: 1.1rem;
}

.status-dot {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--sprout);
  box-shadow: 0 0 0 4px var(--sprout-dim);
  flex: none;
  margin-top: .5rem;
}
.readout[data-state="invalid"] .status-dot {
  background: var(--rose);
  box-shadow: 0 0 0 4px rgba(255, 122, 122, .16);
}

.readout__text {
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--text);
  margin: 0;
}
.readout[data-state="invalid"] .readout__text { color: var(--rose); }

.readout__note {
  color: var(--amber);
  font-size: .85rem;
  margin: .35rem 0 0;
}

/* --- Presets -------------------------------------------------------------- */
.preset {
  background: var(--ink-700);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: .28rem .8rem;
  font-size: .82rem;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.preset:hover {
  color: var(--text);
  border-color: var(--beam);
  background: var(--ink-600);
}

/* Shown when the pasted expression is richer than the quick form can display. */
.quick-note {
  border-left: 2px solid var(--amber);
  background: rgba(242, 181, 68, .07);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .6rem .9rem;
  font-size: .85rem;
  color: var(--text);
}
.quick-note[hidden] { display: none; }

/* --- Field editors -------------------------------------------------------- */
.field {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-700);
  padding: .9rem 1rem;
  transition: border-color .18s ease, background .18s ease;
}
.field + .field { margin-top: .7rem; }
.field[data-active="true"] {
  border-color: var(--beam);
  background: var(--ink-600);
}

.field__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .7rem;
}
.field__name { font-weight: 600; font-size: .92rem; }
.field__token {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--sprout);
  background: var(--sprout-dim);
  border-radius: 6px;
  padding: .1rem .45rem;
}

.field__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .88rem;
}
.field__controls[hidden] { display: none; }

/* --- Value chips ---------------------------------------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  max-height: 8.5rem;
  overflow-y: auto;
  padding: .15rem;
  width: 100%;
}
.chip {
  font-family: var(--font-mono);
  font-size: .74rem;
  min-width: 2.35rem;
  padding: .2rem .35rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--ink-800);
  color: var(--muted);
  transition: all .12s ease;
}
.chip:hover { border-color: var(--beam); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--sprout);
  border-color: var(--sprout);
  color: #10200a;
  font-weight: 700;
}

/* --- Forms ---------------------------------------------------------------- */
.form-control, .form-select {
  background-color: var(--ink-800);
  border-color: var(--line);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  background-color: var(--ink-800);
  border-color: var(--beam);
  color: var(--text);
  box-shadow: 0 0 0 .2rem rgba(154, 151, 255, .18);
}
.form-control::placeholder { color: #5f6b8a; }

.input-narrow { width: 5.5rem; }
.input-mid { width: 8.5rem; }

.expression-input {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: .02em;
}

.btn-sprout {
  background: var(--sprout);
  border: 1px solid var(--sprout);
  color: #10200a;
  font-weight: 600;
}
.btn-sprout:hover { background: #96d861; border-color: #96d861; color: #10200a; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--beam); color: var(--text); }

/* --- Next runs ------------------------------------------------------------ */
.runs { list-style: none; margin: 0; padding: 0; }

.run {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem 0;
  border-bottom: 1px dashed var(--line-soft);
  animation: run-in .22s ease both;
}
.run:last-child { border-bottom: 0; }
.run__when {
  font-family: var(--font-mono);
  font-size: .87rem;
  color: var(--text);
  white-space: nowrap;
}
.run__in { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.run:first-child .run__when { color: var(--sprout); }

@keyframes run-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

/* --- Code output ---------------------------------------------------------- */
.code {
  background: #0a0e1a;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin: 0;
  font-size: .82rem;
  line-height: 1.65;
  color: #c9d2e8;
  overflow-x: auto;
}
.code .kw { color: var(--beam); }
.code .str { color: var(--sprout); }
.code .cmt { color: #5f6b8a; font-style: italic; }

.copy-btn { font-size: .78rem; }

/* --- Cheat sheet ---------------------------------------------------------- */
.cheat { width: 100%; font-size: .88rem; }
.cheat th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line-soft);
}
.cheat td {
  padding: .45rem .75rem .45rem 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.cheat td:first-child {
  font-family: var(--font-mono);
  color: var(--sprout);
  white-space: nowrap;
}
.cheat tr:last-child td { border-bottom: 0; }

/* --- Legal pages ---------------------------------------------------------- */
.legal { max-width: 68ch; }
.legal h2 {
  font-size: 1.12rem;
  margin: 2rem 0 .6rem;
  color: #fff;
}
.legal h2:first-of-type { margin-top: 0; }
.legal p, .legal li { color: var(--muted); }
.legal address { color: var(--muted); font-style: normal; }

/* --- Tabs ----------------------------------------------------------------- */
.nav-pills .nav-link {
  color: var(--muted);
  border-radius: 999px;
  padding: .3rem .95rem;
  font-size: .88rem;
}
.nav-pills .nav-link:hover { color: var(--text); }
.nav-pills .nav-link.active {
  background: var(--beam-dim);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--beam);
}

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 575.98px) {
  .ruler { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .input-narrow { width: 4.75rem; }
  .field__controls { font-size: .84rem; }
}

@media (min-width: 992px) {
  .sticky-column { position: sticky; top: 5.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
