/* Theme: blue glass. Panels are translucent over a soft blue background, buttons are
   glossy blue pills with Material-style hover / pressed / focus states.
   theme.js sets data-theme="light|dark" on <html> before the page is drawn. */
:root {
  color-scheme: light;
  --bg-base: #e8eefb;
  --bg-glow-1: rgba(77, 141, 255, 0.38);
  --bg-glow-2: rgba(26, 63, 143, 0.18);

  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.9);
  --outline: rgba(26, 63, 143, 0.12);
  --shadow: 0 10px 30px rgba(26, 63, 143, 0.10), 0 1px 2px rgba(26, 63, 143, 0.08);

  --field: rgba(255, 255, 255, 0.78);
  --field-border: rgba(26, 63, 143, 0.18);

  --text: #14213d;
  --muted: #55627a;

  --accent: #2f6fde;          /* main blue */
  --accent-2: #4d8dff;        /* lighter blue: top of the button gradient */
  --accent-strong: #1a3f8f;   /* deep blue: text on tonal buttons */
  --accent-text: #ffffff;
  --accent-shadow: rgba(47, 111, 222, 0.35);
  --tonal: rgba(47, 111, 222, 0.10);
  --tonal-hover: rgba(47, 111, 222, 0.18);
  --ring: rgba(77, 141, 255, 0.45);

  --error: #c62828;
  --ok: #1e8a50;
  --logo-main: #1a3f8f;
  --logo-sub: #4d8dff;

  --header-h: 64px;
  --page-w: 1600px;   /* the whole app is centered in this width */
  --control-h: 36px; /* every control in a row (field, select, option chip, button) has this height */
  --control-radius: 6px; /* square-ish buttons, fields and menu items */
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-base: #0b1120;
  --bg-glow-1: rgba(47, 111, 222, 0.32);
  --bg-glow-2: rgba(77, 141, 255, 0.14);

  --glass: rgba(22, 30, 48, 0.58);
  --glass-strong: rgba(16, 23, 40, 0.78);
  --glass-border: rgba(255, 255, 255, 0.08);
  --outline: rgba(143, 180, 255, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);

  --field: rgba(8, 14, 28, 0.55);
  --field-border: rgba(143, 180, 255, 0.18);

  --text: #e6ebf5;
  --muted: #9aa7bd;

  --accent: #3f7ef0;
  --accent-2: #6a9dff;
  --accent-strong: #a9c6ff;
  --accent-shadow: rgba(47, 111, 222, 0.45);
  --tonal: rgba(122, 167, 255, 0.14);
  --tonal-hover: rgba(122, 167, 255, 0.24);
  --ring: rgba(106, 157, 255, 0.5);

  --error: #ff7b7b;
  --ok: #5fd08f;
  --logo-main: #8fb4ff;
  --logo-sub: #3f7ef0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 960px; /* desktop-only page: narrower windows scroll instead of squeezing the layout */
  color: var(--text);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(900px 600px at 10% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(800px 600px at 100% 100%, var(--bg-glow-2), transparent 70%);
  background-attachment: fixed;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: background-color 0.3s, color 0.3s;
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.9em; }

/* Read by screen readers, not shown (e.g. the "Input" label of text boxes) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}


/* Glass surfaces */
.topbar, .sidebar, .tool, #output-box, .guide {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  transition: background-color 0.3s, border-color 0.3s;
}

/* Header: text-only logo on the left, language picker and theme switch on the right */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: var(--glass-strong);
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--outline);
}

.topbar-inner {
  width: 100%;
  max-width: var(--page-w);
  height: 100%;
  margin: 0 auto;
  /* 14px: sidebar border (1px) + sidebar padding (12px) + 1px to look centered over the menu items */
  padding: 0 24px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo: SVG text stretched to a fixed width (see index.html), so it lines up with the menu in every browser */
.logo { display: block; line-height: 0; text-decoration: none; user-select: none; }
.logo-svg { display: block; overflow: visible; }
.logo-main { fill: var(--logo-main); font-size: 26px; font-weight: 800; }
.logo-sub { fill: var(--logo-sub); font-size: 13px; font-weight: 700; }

.topbar-actions { display: flex; align-items: center; gap: 20px; }
.topbar-links { display: flex; align-items: center; gap: 18px; }
.topbar-links a { font-size: 0.85rem; font-weight: 600; color: inherit; text-decoration: none; opacity: 0.75; }
.topbar-links a:hover, .topbar-links a.active { opacity: 1; color: var(--accent); }
.topbar .lang { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.topbar .lang select { padding: 5px 10px; font-size: 0.85rem; }

/* Big light / dark switch: the knob slides and shows the current mode */
.theme-switch {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 999px;
}
.theme-switch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.theme-switch-track {
  position: relative;
  display: block;
  width: 76px;
  height: 38px;
  border-radius: 999px;
  background: var(--tonal);
  border: 1px solid var(--outline);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}
.theme-switch svg { width: 18px; height: 18px; }
.track-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  opacity: 0.7;
}
.track-icon.sun { left: 9px; }
.track-icon.moon { right: 9px; }
.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-text);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 8px var(--accent-shadow);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.theme-switch-knob svg { grid-area: 1 / 1; }
.theme-switch[aria-checked="true"] .theme-switch-knob { transform: translateX(38px); }
.theme-switch-knob .moon,
.theme-switch[aria-checked="true"] .theme-switch-knob .sun { display: none; }
.theme-switch[aria-checked="true"] .theme-switch-knob .moon { display: block; }
.theme-switch:hover .theme-switch-knob { filter: brightness(1.08); }

/* Layout: fixed-width sidebar + scrolling content */
.layout {
  display: flex;
  max-width: var(--page-w);
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  flex: 0 0 220px;
  border-right: 1px solid var(--outline);
  border-left: 1px solid var(--outline);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 8px 12px 20px;
}

#menu h2 {
  margin: 16px 10px 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

#menu a {
  position: relative;
  z-index: 0; /* the blue layer (::before) stays behind the text */
  display: block;
  margin: 2px 0;
  padding: 6px 12px;
  border-radius: var(--control-radius);
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.15s, color 0.3s;
}
#menu a:hover { background: var(--tonal); }
#menu a.active { color: var(--accent-text); background: transparent; }
/* The blue of the selected item is a layer behind the text, so it can be animated with transform and opacity only
   (cheap for the browser, smooth even without hardware acceleration). */
#menu a.active::before,
#menu a.just-left::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 3px 10px var(--accent-shadow);
  transform-origin: left center;
}
/* After a tool switch (app.js): the new item fills from left to right while fading in, the old one fades out. */
#menu a.just-picked::before { animation: menu-pick 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
#menu a.just-left::before { animation: menu-leave 0.3s ease-out forwards; }
@keyframes menu-pick {
  from { transform: scaleX(0); opacity: 0; }
  to { transform: scaleX(1); opacity: 1; }
}
@keyframes menu-leave {
  from { opacity: 1; }
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #menu a.just-picked::before, #menu a.just-left::before { animation: none; }
  #menu a.just-left::before { display: none; }
  #menu a { transition: none; }
}

/* A column, so the footer can sit at the bottom of short pages */
main { flex: 1; min-width: 0; padding: 24px 24px 20px; display: flex; flex-direction: column; }

/* Ad slots: sizes are reserved up front so loading ads never shifts the page */
.ad-rail { flex: 0 0 300px; padding: 24px 24px 40px 0; }
.ad-sticky { position: sticky; top: calc(var(--header-h) + 24px); }
.ad-slot { overflow: hidden; border-radius: var(--control-radius); }
.ad-banner { width: 100%; max-width: 728px; min-height: 90px; margin-top: 16px; }
.ad-tall { width: 300px; height: 600px; }
.ad-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  background: var(--glass);
  border: 1px dashed var(--field-border);
}
.ad-placeholder::after { content: attr(data-size); }
@media (max-width: 1439px) {
  .ad-rail { display: none; }
}

/* Tools */
.tool {
  display: none;
  padding: 20px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tool.active { display: block; }
.tool > h1, .tool > h2 { margin: 0 0 4px; font-size: 1.25rem; }
.desc { margin: 0 0 16px; color: var(--muted); max-width: 70ch; }

label { display: block; color: var(--muted); font-size: 0.9rem; }
.row label { display: inline-flex; flex-direction: column; gap: 4px; }

/* Checkbox options are pill chips with the same height as fields and buttons, so a row lines up.
   The real checkbox stays inside (keyboard and screen readers); the chip turns blue when checked. */
.row label.check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 14px 0 10px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.row label.check:hover { background: var(--tonal); }
.row label.check:has(input:checked) {
  color: var(--accent-strong);
  background: var(--tonal);
  border-color: var(--accent);
}
.row label.check:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--ring); }
.row label.check input { outline: none; }

textarea, input, select {
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: var(--control-radius);
  padding: 7px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
textarea { width: 100%; margin-top: 4px; font-family: var(--mono); resize: vertical; }
input:not([type="checkbox"]), select { height: var(--control-h); padding-top: 0; padding-bottom: 0; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
input:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 14px; }

/* Buttons. Primary: glossy blue, square corners. Tonal (copy): tinted. */
button.run, #copy, button.copy-small {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--control-radius);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, background-color 0.2s, filter 0.2s;
}
button.run {
  height: var(--control-h);
  padding: 0 22px;
  color: var(--accent-text);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 14px var(--accent-shadow);
}
button.run:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 20px var(--accent-shadow);
}
button.run:active {
  transform: translateY(0) scale(0.98);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 6px var(--accent-shadow);
}

#copy, button.copy-small {
  color: var(--accent-strong);
  background: var(--tonal);
}
#copy { padding: 5px 16px; }
button.copy-small { padding: 3px 12px; font-size: 0.85rem; }
#copy:hover, button.copy-small:hover { background: var(--tonal-hover); }
#copy:active, button.copy-small:active { transform: scale(0.97); }

button.run:focus-visible, #copy:focus-visible, button.copy-small:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.hint { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

#output-box {
  margin-top: 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.output-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--outline);
  color: var(--muted);
}
#output { margin: 0; padding: 14px 16px; min-height: 3em; font-family: var(--mono); white-space: pre-wrap; word-break: break-all; }
#output.error { color: var(--error); }

[hidden] { display: none !important; }

/* Status line under a tool (e.g. "Valid JSON") */
.status:empty { display: none; }
.status.ok { color: var(--ok); font-weight: 600; }

/* Regex tester */
label.field { margin-top: 14px; }
.status.error { color: var(--error); }
.regex-preview {
  margin: 12px 0 0;
  padding: 12px 14px;
  max-height: 360px;
  overflow: auto;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: var(--control-radius);
}
.regex-preview:empty { display: none; }
mark {
  color: inherit;
  border-radius: 3px;
  background: rgba(77, 141, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(47, 111, 222, 0.45);
}
mark.alt { background: rgba(255, 170, 60, 0.3); box-shadow: inset 0 0 0 1px rgba(220, 130, 20, 0.5); }
mark.empty { display: inline-block; width: 2px; height: 1.1em; vertical-align: text-bottom; background: var(--accent); }
.regex-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 0.9rem; }
.regex-table:empty { display: none; }
.regex-table th, .regex-table td { padding: 6px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--outline); }
.regex-table th { color: var(--muted); font-weight: 600; }
.regex-table td code { word-break: break-all; }
.regex-table .unset { color: var(--muted); font-style: italic; }

/* 404 page */
.not-found { text-align: center; padding: 48px 20px; }
.big-404 {
  font-size: 7rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(180deg, var(--logo-sub), var(--logo-main));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.not-found h1 { margin: 12px 0 0; font-size: 1.5rem; }
.joke { margin: 20px auto 8px; max-width: 52ch; font-size: 1.2rem; font-style: italic; }
.not-found .row { justify-content: center; align-items: center; }
a.home-link {
  display: inline-flex;
  align-items: center;
  height: var(--control-h);
  padding: 0 22px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-text);
  border-radius: var(--control-radius);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 14px var(--accent-shadow);
}
a.home-link:hover { filter: brightness(1.06); }

/* Site pages (privacy policy...): readable text column */
.info-page p { max-width: 72ch; line-height: 1.6; }
.info-page .updated { color: var(--muted); font-size: 0.85rem; }

/* Timestamp converter */
.now-grid { margin: 0 0 4px; }
.now-grid .case-value { font-variant-numeric: tabular-nums; }

/* Cron expression */
.tool h3 { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--outline); font-size: 1.05rem; }
.row label.grow { flex: 1; min-width: 260px; }
.row label.grow input { width: 100%; font-family: var(--mono); }
.runs { margin: 6px 0 0; padding-left: 24px; font-family: var(--mono); font-size: 0.9rem; }
.runs:empty { display: none; }
.case-value.unsupported { color: var(--muted); font-family: inherit; font-style: italic; }

/* Case converter */
.case-grid { margin-top: 16px; display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; border-top: 1px solid var(--outline); }
.case-grid > * { padding: 8px 6px; border-bottom: 1px solid var(--outline); display: flex; align-items: center; }
.case-label { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.case-value { font-family: var(--mono); white-space: pre-wrap; word-break: break-all; }
.case-grid .error { grid-column: 1 / -1; color: var(--error); }

/* Home page: the intro and the note on who made it, together in a box */
.home-intro {
  margin: 8px 0 8px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--tonal);
  border-left: 3px solid var(--accent);
  color: var(--muted);
  line-height: 1.6;
}
.home-intro p { margin: 0; }
.home-intro p + p { margin-top: 10px; }

/* Home page: every tool as a card (grouped like the menu), then what's new */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  border-radius: 12px;
  background: var(--tonal);
  border: 1px solid var(--outline);
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}
.tool-card:hover { background: var(--tonal-hover); border-color: var(--accent); transform: translateY(-1px); }
.tool-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.tool-card strong { color: var(--accent-strong); }
.tool-card span {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.changelog { list-style: none; margin: 14px 0 0; padding: 0; }
.changelog li {
  display: grid;
  grid-template-columns: 11em 1fr;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--outline);
  line-height: 1.5;
}
.changelog li:last-child { border-bottom: 0; }
.changelog time { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* How to use + FAQ of a tool, under the result */
.guide {
  margin-top: 16px;
  padding: 4px 20px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.guide h2 { margin: 18px 0 6px; font-size: 1.1rem; }
.guide h3 { margin: 16px 0 4px; font-size: 0.98rem; }
.guide p { margin: 0; max-width: 75ch; line-height: 1.6; color: var(--muted); }

/* Footer: small grey line at the bottom of the main column */
.site-footer {
  margin-top: auto;
  padding: 32px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}
.site-footer a { color: inherit; text-decoration: none; font-weight: 600; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
