/* MEDiscuss Search - one stylesheet, no frameworks.
   Shared with the Links & QR tool so the two look like one site.
   Colours follow the MEDiscuss mark: maroon, with the gold and teal of the
   ring as secondaries, on the same dark navy bar the CDSS uses. */

:root {
  /* The bar at the top keeps its colours in both themes, as on the CDSS. */
  --bar: #141b23;
  --bar-ink: #eef2f6;
  --bar-muted: #a3b1bd;
  --bar-line: #273240;
  --bar-hover: #1e2833;

  --bg: #f7f5f3;
  --card: #ffffff;
  --ink: #1c2229;
  --muted: #66717c;
  --line: #e4dfda;
  --accent: #8f1214;
  --accent-ink: #ffffff;
  --accent-soft: #fbf1f0;
  --teal: #0e8f79;
  --gold: #b8801a;

  --ok-bg: #e8f5f1;   --ok-line: #a5d8c9;   --ok-ink: #10564a;
  --warn-bg: #fdf4e3; --warn-line: #e8cd97; --warn-ink: #6d4c12;
  --bad-bg: #fdeeed;  --bad-line: #eeb6b3;  --bad-ink: #7d1a18;

  --radius: 10px;
}

/* System preference, unless the reader has explicitly chosen light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10161d;
    --card: #18202a;
    --ink: #e7edf3;
    --muted: #94a3b0;
    --line: #27323d;
    --accent: #e28d85;
    --accent-ink: #2a0b09;
    --accent-soft: #241518;
    --teal: #2bb39a;
    --gold: #dda63a;

    --ok-bg: #14302a;   --ok-line: #2e5f53;   --ok-ink: #a9dfd0;
    --warn-bg: #332a17; --warn-line: #6b5623; --warn-ink: #f0d9a4;
    --bad-bg: #341f1e;  --bad-line: #6d3733;  --bad-ink: #f3b9b4;
  }
}

/* The reader's explicit choice wins in both directions. */
:root[data-theme="dark"] {
  --bg: #10161d;
  --card: #18202a;
  --ink: #e7edf3;
  --muted: #94a3b0;
  --line: #27323d;
  --accent: #e28d85;
  --accent-ink: #2a0b09;
  --accent-soft: #241518;
  --teal: #2bb39a;
  --gold: #dda63a;

  --ok-bg: #14302a;   --ok-line: #2e5f53;   --ok-ink: #a9dfd0;
  --warn-bg: #332a17; --warn-line: #6b5623; --warn-ink: #f0d9a4;
  --bad-bg: #341f1e;  --bad-line: #6d3733;  --bad-ink: #f3b9b4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;          /* keeps the footer bar at the bottom */
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}
main.wrap { flex: 1 0 auto; width: 100%; }
.topbar, .foot { flex: none; }

.wrap { max-width: 62rem; margin: 0 auto; padding: 0 1.25rem; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: 0 0 8px 0; z-index: 10;
}
.skip:focus { left: 0; }

/* The MEDiscuss bar ------------------------------------------------- */

.topbar {
  background: var(--bar);
  border-bottom: 1px solid var(--bar-line);
  margin-bottom: 2rem;
}
.topbar .wrap {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: .5rem 1.1rem;
  padding-top: .7rem; padding-bottom: .7rem;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { display: block; height: 40px; width: auto; }
.brand .wordmark { color: var(--bar-ink); font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }

.tool {
  color: var(--bar-muted);
  font-size: .82rem; letter-spacing: .09em; text-transform: uppercase;
  padding: .2rem .55rem;
  border: 1px solid var(--bar-line); border-radius: 999px;
  white-space: nowrap;
}

.topnav { display: flex; gap: .3rem; margin-left: auto; }
.topnav a {
  color: var(--bar-muted); text-decoration: none; font-size: .95rem;
  padding: .4rem .7rem; border-radius: 7px;
}
.topnav a:hover, .topnav a:focus-visible { color: var(--bar-ink); background: var(--bar-hover); }

.theme { display: flex; gap: .15rem; padding: .15rem; border: 1px solid var(--bar-line); border-radius: 999px; }
.theme button {
  display: grid; place-items: center;
  width: 2rem; height: 2rem; padding: 0; cursor: pointer;
  background: none; border: 0; border-radius: 999px;
  color: var(--bar-muted);
}
.theme button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme button[data-theme-set="dark"] svg { fill: currentColor; stroke: none; }
.theme button:hover { color: var(--bar-ink); background: var(--bar-hover); }
.theme button[aria-pressed="true"] { color: #141b23; background: var(--bar-ink); }

@media (max-width: 34rem) {
  .tool { display: none; }
  .topnav { margin-left: 0; }
  .brand img { height: 34px; }
}

/* Type -------------------------------------------------------------- */

h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.lede { color: var(--muted); max-width: 42rem; }
.small { font-size: .88rem; color: var(--muted); }
.tiny { font-size: .8rem; color: var(--muted); }
.hint { font-size: .85rem; color: var(--muted); margin: .3rem 0 1rem; }
.opt { font-weight: 400; color: var(--muted); font-size: .85em; }
.empty { color: var(--muted); font-style: italic; }

/* Boxes ------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin: 0 0 1.75rem;
}
.card.narrow { max-width: 24rem; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 1rem; }

.note { border-radius: var(--radius); padding: .9rem 1.1rem; margin: 0 0 1.5rem; border: 1px solid; }
.note p:last-child { margin: 0; }
.note-ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-ink); }
.note-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.note-bad  { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad-ink); }
.note a { color: inherit; }

/* Forms ------------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 .35rem; }
input[type=text], input[type=search], input[type=password], input[type=number],
input[type=url], textarea, select {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input[type=color] { width: 100%; height: 2.6rem; padding: .2rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
form.card > input, form.card > textarea, form.card > .prefixed { margin-bottom: 1rem; }
.stack > * { margin-bottom: .8rem; }

.prefixed { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.prefixed span { padding: .6rem .6rem; color: var(--muted); font-size: .9rem; white-space: nowrap; border-right: 1px solid var(--line); display: flex; align-items: center; }
.prefixed input { border: 0; border-radius: 0; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.controls .check { display: flex; flex-direction: column; justify-content: flex-end; }
.controls .check label { font-weight: 400; display: flex; gap: .45rem; align-items: center; }
.controls .check input { width: auto; }

.templates { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: -.4rem 0 1rem; }
.templates span { font-size: .85rem; color: var(--muted); }
.templates button {
  font: inherit; font-size: .82rem; padding: .25rem .6rem; cursor: pointer;
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
}
.templates button:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* A field only a robot fills in. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-block; cursor: pointer;
  font: inherit; font-size: .95rem; font-weight: 600;
  padding: .6rem 1.1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); background: var(--accent); }
.btn.ghost { background: transparent; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1rem 0; }

/* Results ----------------------------------------------------------- */

.result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.75rem; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.75rem; align-items: start; }
@media (max-width: 40rem) { .result-grid { grid-template-columns: 1fr; } }

.shorturl { font-size: 1.3rem; font-weight: 700; word-break: break-all; margin-bottom: .3rem; }
.dest { color: var(--muted); font-size: .9rem; word-break: break-all; }
.dest span { color: var(--ink); }

.qrbox { margin: 0; text-align: center; }
.qrbox img { display: block; width: 260px; height: 260px; max-width: 100%; flex: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; }
.qrbox.big img { width: 320px; height: 320px; }
.qrbox figcaption { font-size: .82rem; color: var(--muted); margin-top: .5rem; }

.explain ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.explain li { margin-bottom: .4rem; }

/* Leaving-the-site page --------------------------------------------- */

.leaving { max-width: 40rem; }
.destbox { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.5rem 0; }
.destbox .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.destbox .host { font-size: 1.2rem; font-weight: 700; margin: .2rem 0 .3rem; word-break: break-all; }
.destbox .full { font-size: .85rem; color: var(--muted); word-break: break-all; margin: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 1.25rem 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.spark rect { fill: var(--teal); }

/* Admin ------------------------------------------------------------- */

.adminhead { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; }
.adminhead p { margin: 0; display: flex; gap: .5rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; font-size: .85rem; color: var(--muted); }
.tile .n { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.2; }

.filterbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.filterbar input { flex: 1 1 14rem; }
.filterbar select { flex: 0 1 14rem; }

table.links { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .9rem; }
table.links th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
table.links td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.links tr:last-child td { border-bottom: 0; }
table.links .code { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
table.links .label { display: block; font-size: .82rem; color: var(--muted); }
table.links .dest span { display: block; }
table.links .num { text-align: right; font-variant-numeric: tabular-nums; }
table.links .actions form { display: flex; flex-wrap: wrap; gap: .3rem; }
@media (max-width: 52rem) {
  table.links, table.links thead, table.links tbody, table.links tr, table.links td { display: block; width: 100%; }
  table.links thead { display: none; }
  table.links tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.links td { border: 0; padding: .25rem .8rem; }
}

.mini { font: inherit; font-size: .78rem; padding: .25rem .55rem; cursor: pointer; background: var(--bg); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; }
.mini:hover { color: var(--accent); border-color: var(--accent); }
.mini.danger:hover { color: var(--bad-ink); border-color: var(--bad-line); background: var(--bad-bg); }
details.edit { margin-top: .4rem; }
details.edit summary { display: inline-block; }
details.edit input { font-size: .85rem; }

.pager { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0 2rem; }
.pager a, .pager .here { padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-size: .85rem; }
.pager .here { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.25rem; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
ul.plain li:last-child { border-bottom: 0; }
form.inline { display: inline-flex; gap: .3rem; align-items: center; margin: 0; }
form.inline input { width: auto; flex: 1 1 8rem; }

/* The link bar at the foot ------------------------------------------ */

.foot {
  margin-top: 3rem;
  background: var(--bar);
  border-top: 1px solid var(--bar-line);
  padding: 1.5rem 0 2rem;
}
.footlinks { display: flex; flex-wrap: wrap; gap: .25rem .4rem; margin-bottom: .9rem; }
.footlinks a {
  color: var(--bar-muted); text-decoration: none; font-size: .92rem; font-weight: 600;
  padding: .35rem .7rem; border-radius: 7px;
}
.footlinks a:hover, .footlinks a:focus-visible { color: var(--bar-ink); background: var(--bar-hover); }
.footlinks .admin { margin-left: auto; font-weight: 400; }
.footnote { color: var(--bar-muted); font-size: .84rem; margin: 0; max-width: 46rem; opacity: .85; }
@media (max-width: 34rem) { .footlinks .admin { margin-left: 0; } }


/* Search ------------------------------------------------------------ */

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

.searchbox {
  display: flex; gap: .6rem; align-items: stretch;
  margin: 0 0 1.25rem; max-width: 44rem;
}
.searchbox input[type=search] {
  flex: 1 1 auto; font-size: 1.05rem; padding: .7rem .9rem;
  background: var(--card);
}
.searchbox .btn { flex: none; }
@media (max-width: 30rem) {
  .searchbox { flex-wrap: wrap; }
  .searchbox input[type=search] { flex: 1 1 100%; }
}

.resultcount { margin: 0 0 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .85rem; padding: .3rem .75rem;
  color: var(--muted); text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
}
.chip b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
a.chip:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on b { color: var(--accent-ink); }

ol.results { list-style: none; margin: 0 0 2rem; padding: 0; }
ol.results > li {
  padding: 1.1rem 0; border-bottom: 1px solid var(--line);
}
ol.results > li:first-child { padding-top: .2rem; }
ol.results > li:last-child { border-bottom: 0; }

.rtitle { font-size: 1.12rem; font-weight: 700; text-decoration: none; line-height: 1.3; }
.rtitle:hover { text-decoration: underline; }
.rurl { font-size: .82rem; color: var(--teal); margin: .15rem 0 .35rem; word-break: break-word; }
.rsnip { margin: 0 0 .35rem; color: var(--ink); font-size: .95rem; }
.rmeta { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .78rem; color: var(--muted); }

mark {
  background: var(--accent-soft); color: inherit;
  font-weight: 600; padding: 0 .1em; border-radius: 3px;
}
:root[data-theme="dark"] mark { background: #3a2222; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) mark { background: #3a2222; }
}

.pager .gap { padding: .3rem .2rem; color: var(--muted); }
