/* style.css: the look of the whole control panel. One file, no frameworks.
   The idea: Sonar is a sonar. Its status is a ping, with rings that pulse out while it runs and
   stop when it's paused. That ping is the one bold thing. Everything else stays calm. */

/* Colors live in variables, so changing the theme means changing one line each. */
:root {
  --abyss: #0f2c3f;      /* deep water: the header and the text */
  --trench: #0a1f2d;     /* the darker band under the header */
  --tidewater: #1f6f8b;  /* links and buttons */
  --tide-dark: #17566c;  /* buttons when you point at them */
  --seafoam: #e6f0ef;    /* the page background */
  --shell: #fbfdfc;      /* cards and tables */
  --reef: #c4d8d9;       /* borders */
  --silt: #52666f;       /* small grey text */
  --kelp: #3c7a4e;       /* running, done, good news */
  --anemone: #c8402f;    /* paused, danger, errors */
  --sunlit: #f2c14e;     /* "new" and "changed" */
  --spray: #cfe2e4;      /* light text on the dark header */

  /* Headings use a narrow, sturdy face (like the lettering on a ship's gauge) if the device has one.
     Windows has Bahnschrift, Macs have DIN Alternate. Anything else gets the system font. */
  --gauge: "Bahnschrift", "DIN Alternate", "Avenir Next Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* box-sizing: border-box makes width include padding, which is easier to reason about */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--abyss);
  background: var(--seafoam);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

h1, h2, legend { font-family: var(--gauge); font-weight: 600; line-height: 1.2; }
h1 { font-size: 2rem; margin: 0 0 20px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 28px 0 10px; }
p, li { max-width: 72ch; }               /* long lines are hard to read */

a { color: var(--tidewater); text-underline-offset: 3px; }
a:hover { color: var(--tide-dark); }
code {
  background: var(--seafoam);
  border: 1px solid var(--reef);
  padding: 0 5px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* Keyboard users see exactly where they are. :focus-visible skips the ring for mouse clicks. */
:focus-visible { outline: 3px solid var(--sunlit); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header: the brand, who you are, and the bot's band ---------- */

.topbar { background: var(--abyss); color: white; }
.topbar-inner {
  display: flex;                    /* flexbox puts children in a row */
  justify-content: space-between;   /* brand on the left, "who" on the right */
  align-items: center;
  gap: 12px;
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
}
.topbar a, .topbar .link-button { color: white; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--gauge);
  font-weight: 600;
  font-size: 1.15rem;
  text-decoration: none;
}
/* The brand mark is a tiny sonar: a dot inside a ring, drawn with CSS instead of a picture */
.brand-mark {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--spray);
  background: radial-gradient(circle, var(--sunlit) 0 3px, transparent 3.5px);
}
.who { display: flex; align-items: center; gap: 14px; font-size: 0.95rem; }
.who form { margin: 0; }
.role { color: var(--spray); }

.bot-band {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px 0;
}
.bot-status { display: flex; align-items: center; gap: 16px; padding-bottom: 14px; }
.all-bots { display: block; font-size: 0.85rem; color: var(--spray); }
.bot-name { font-family: var(--gauge); font-size: 1.9rem; font-weight: 600; margin-right: 10px; vertical-align: middle; }

/* ---------- The sonar ping ---------- */

/* The dot in the middle, and two rings (::before and ::after) that grow and fade like a ping */
.sonar {
  position: relative;
  flex: none;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(207, 226, 228, 0.35);
  background: radial-gradient(circle, var(--kelp) 0 7px, transparent 7.5px),
              radial-gradient(circle, transparent 0 15px, rgba(207, 226, 228, 0.25) 15.5px 16.5px, transparent 17px);
}
.sonar::before, .sonar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #7fd1a0;
  opacity: 0;
}
.sonar.is-running::before { animation: ping 2.8s ease-out infinite; }
.sonar.is-running::after { animation: ping 2.8s ease-out 1.4s infinite; }   /* the second ring starts halfway */
.sonar.is-paused {
  background: radial-gradient(circle, var(--anemone) 0 7px, transparent 7.5px),
              radial-gradient(circle, transparent 0 15px, rgba(207, 226, 228, 0.25) 15.5px 16.5px, transparent 17px);
}

@keyframes ping {
  from { transform: scale(0.25); opacity: 0.9; }
  to   { transform: scale(1.35); opacity: 0; }
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px 22px;
  overflow-x: auto;                 /* on a phone, the tabs scroll sideways instead of wrapping */
  white-space: nowrap;
}
.tabs a {
  color: var(--spray);
  text-decoration: none;
  padding: 8px 2px 12px;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: white; }
.tabs a[aria-current="page"] { color: white; font-weight: 600; border-bottom-color: var(--sunlit); }

/* ---------- Badges, pills, and notes ---------- */

.badge {
  display: inline-block;
  background: var(--sunlit);
  color: #3b2c00;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;            /* a big radius makes a pill shape */
  vertical-align: middle;
}
.pill {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  vertical-align: middle;
}
.pill.running { background: rgba(127, 209, 160, 0.18); color: #9fe0b8; }
.pill.paused { background: var(--anemone); color: white; }

.hint { color: var(--silt); font-size: 0.9rem; margin: 4px 0 0; }

/* Flash notes get a colored edge on the left, so "saved" and "error" read at a glance */
.flash {
  background: var(--shell);
  border: 1px solid var(--reef);
  border-left: 5px solid var(--tidewater);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0 0 18px;
}
.flash.error { border-left-color: var(--anemone); background: #fcf1ef; }
.flash.success { border-left-color: var(--kelp); }

/* ---------- Cards ---------- */

.card {
  background: var(--shell);
  border: 1px solid var(--reef);
  border-radius: 8px;
  padding: 18px 22px;
  margin: 0 0 18px;
}
.card h2 { margin-top: 0; }

/* ---------- Buttons ---------- */

button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  background: var(--tidewater);
  color: white;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--tide-dark); color: white; }
button.danger { background: var(--anemone); }
button.danger:hover { background: #a93526; }
button.go { background: var(--kelp); }
button.go:hover { background: #2f6340; }
button.small { padding: 4px 12px; font-size: 0.85rem; }
.link-button { background: none; padding: 0; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { background: none; }

/* ---------- The login page: a big sonar as the first thing you see ---------- */

.login { max-width: 440px; margin: 24px auto; text-align: center; }
.login h1 { font-size: 2.4rem; margin-bottom: 6px; }
.login p { margin: 0 auto 18px; }
.sonar-hero {
  position: relative;
  width: 220px; height: 220px;
  margin: 0 auto 22px;
  border-radius: 50%;
  /* Four rings and a dot, like distance marks on a sonar screen */
  background:
    radial-gradient(circle, var(--tidewater) 0 9px, transparent 9.5px),
    repeating-radial-gradient(circle, transparent 0 26px, var(--reef) 26px 27.5px, transparent 27.5px 28px);
}
/* One ping sweeps out when the page opens, then rests */
.sonar-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--tidewater);
  opacity: 0;
  animation: ping 2.2s ease-out 0.3s 2;
}

/* ---------- What's New: a timeline, newest at the top ---------- */

.timeline { position: relative; padding-left: 34px; }
/* The line the versions hang on */
.timeline::before {
  content: "";
  position: absolute;
  left: 9px; top: 10px; bottom: 10px;
  width: 2px;
  background: var(--reef);
}
.release { position: relative; margin: 0 0 30px; }
.release h2 { margin: 0; font-size: 1.35rem; }
.release ul { margin: 10px 0 0; padding-left: 20px; }
.release li { margin-bottom: 6px; }
/* Each version's stop on the line */
.release::before {
  content: "";
  position: absolute;
  left: -31px; top: 6px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--seafoam);
  border: 2px solid var(--tidewater);
}
.release.is-new::before { background: var(--sunlit); border-color: #b88a14; }

/* ---------- The settings form ---------- */

fieldset { min-width: 0; }               /* stops wide boxes from stretching the page */
legend { font-size: 1.2rem; padding: 0 8px; margin-left: -8px; }

.fields {
  display: grid;                         /* grid: boxes in columns that wrap */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px 24px;
}
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input[type="text"], .field input[type="number"], .field input[type="time"],
.field input[type="url"], .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #a9c3c6;
  border-radius: 6px;
  background: white;
  color: var(--abyss);
  font: inherit;
}
.field input:focus-visible, .field select:focus-visible { outline-offset: 0; border-color: var(--tidewater); }
.field label.switch { display: flex; align-items: center; gap: 10px; }
.field label.switch input { width: 20px; height: 20px; accent-color: var(--tidewater); }
.field.changed input, .field.changed select { border-color: #d4a12a; background: #fff8e3; }
.field.has-error input, .field.has-error select { border-color: var(--anemone); background: #fcf1ef; }
.error-text { color: var(--anemone); font-size: 0.9rem; margin: 4px 0 0; }
fieldset:disabled { opacity: 0.85; }

/* The kill switch is the most important box, so its edge shows the state */
.kill-switch { border-left: 6px solid var(--kelp); }
.kill-switch.is-paused { border-color: var(--anemone); border-left-width: 6px; background: #fcf1ef; }

/* The save bar sticks to the bottom of the window while you scroll the form */
.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  background: var(--seafoam);
  border-top: 1px solid var(--reef);
}
#unsaved-note { color: #7a5a00; font-weight: 600; }

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;                      /* scroll sideways on a phone */
  border: 1px solid var(--reef);
  border-radius: 8px;
  background: var(--shell);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--reef); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
th { background: #dcebea; font-weight: 600; font-size: 0.92rem; }
td form { margin: 0; }
tr[data-status="failed"] .status { color: var(--anemone); font-weight: 600; }
tr[data-status="done"] .status { color: var(--kelp); font-weight: 600; }
.hint + .table-wrap { margin-top: 18px; }   /* room between a page's note and its table */

.test-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.test-buttons form { margin: 0; }

/* The page that lists bots, when someone has more than one */
.bot-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.bot-list .card { margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bot-list a { font-family: var(--gauge); font-size: 1.3rem; font-weight: 600; }

/* Error and "ask for access" pages: one short card in the middle */
.narrow { max-width: 460px; margin: 40px auto; text-align: center; }
.narrow p { margin-left: auto; margin-right: auto; }

/* Hidden on screen, but screen readers still read it out */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  .bot-band { padding-top: 4px; }
  .bot-name { font-size: 1.5rem; }
  .sonar { width: 42px; height: 42px; }
  .who .role { display: none; }          /* keeps the top bar on one line */
  .sonar-hero { width: 170px; height: 170px; }
  .card { padding: 16px; }
}

/* People who turn off motion in their device settings get a still sonar */
@media (prefers-reduced-motion: reduce) {
  .sonar::before, .sonar::after, .sonar-hero::after { animation: none; }
}
