/* theme.css: Mac Lookup. "Rack-room instrument": a calm, labelled work surface with monospace
   readouts. Signature: every result row carries a 4px status edge, like a coloured patch lead
   (teal joined, amber no ip, slate no port). Loaded after styles.css, so these rules win.
   Structural template rules (.ad-slot height, footer, consent banner) are styled, never resized. */

:root {
  color-scheme: light dark;

  /* Palette (light). Every text pair below meets WCAG AA. */
  --bg: #f5f7f6;
  --surface: #ffffff;
  --raised: #eaefec;
  --text: #16201c;          /* 15.9:1 on --surface */
  --muted: #4b5852;         /* 7.1:1 on --surface, 6.6:1 on --bg */
  --border: #c9d3ce;
  --border-strong: #73857c;
  --accent: #0b6b60;        /* white on it 6.3:1 */
  --accent-hover: #095a51;
  --accent-active: #074840;
  --accent-tint: #0b6b6014;
  --accent-text: #0a5f55;   /* links, 7.3:1 on --surface */
  --on-accent: #ffffff;
  --success: #17703a;       /* 5.9:1 on --surface */
  --warning: #8a5300;       /* 6.0:1 on --surface */
  --warning-edge: #d8920f;
  --danger: #b42318;        /* 6.5:1 on --surface */
  --danger-tint: #b4231810;
  --slate-edge: #7d8a99;
  --line: var(--border);    /* the template's own rule colour */

  /* Type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --text-xs: 0.75rem;   /* 12px column labels, caps */
  --text-sm: 0.875rem;  /* 14px table, file names, notes */
  --text-body: 1.0625rem; /* 17px */
  --text-lede: 1.1875rem; /* 19px */
  --text-h2: 1.375rem;  /* 22px */
  --text-title: clamp(1.75rem, 4.5vw, 2.5rem);

  /* Space, radii, shadow, motion */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --shadow-1: 0 1px 2px #16201c0f, 0 1px 1px #16201c0a;
  --shadow-2: 0 8px 28px #16201c1f, 0 2px 6px #16201c12;
  --edge: 4px;
  --fast: 160ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --surface: #151d1a;
    --raised: #1c2622;
    --text: #e4ebe8;          /* 13.9:1 on --surface */
    --muted: #a2b1aa;         /* 7.6:1 on --surface */
    --border: #2d3a35;
    --border-strong: #687b72;
    --accent: #3fc2ad;        /* --on-accent on it 9.0:1 */
    --accent-hover: #5fd0be;
    --accent-active: #2fa995;
    --accent-tint: #3fc2ad1c;
    --accent-text: #74dccb;   /* 10.1:1 on --surface */
    --on-accent: #062019;
    --success: #6bd690;
    --warning: #f2b85a;
    --warning-edge: #e0a03a;
    --danger: #ff8f84;        /* 7.4:1 on --surface */
    --danger-tint: #ff8f8414;
    --slate-edge: #7f8d9c;
    --shadow-1: 0 1px 2px #0006;
    --shadow-2: 0 10px 30px #0008, 0 2px 6px #0005;
  }
}

/* ---------- Page ---------- */
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--text-body)/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
header { border-bottom: 1px solid var(--border); }
.brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-weight: 700; letter-spacing: -0.01em; color: var(--text);
}
/* The mark: three port squares drawn in CSS, the middle one lit. */
.brand::before {
  content: ""; width: 22px; height: 12px; flex: none;
  border-radius: 3px;
  background:
    linear-gradient(var(--accent), var(--accent)) 8px 2px / 6px 8px no-repeat,
    linear-gradient(var(--border-strong), var(--border-strong)) 1px 2px / 6px 8px no-repeat,
    linear-gradient(var(--border-strong), var(--border-strong)) 15px 2px / 6px 8px no-repeat;
  outline: 1.5px solid var(--border-strong); outline-offset: -1px;
}
header nav a { color: var(--muted); text-decoration: none; padding: 0 var(--space-2); border-radius: var(--radius-s); }
header nav a:hover { color: var(--text); background: var(--raised); }

h1 { font-size: var(--text-title); letter-spacing: -0.02em; margin: var(--space-5) 0 var(--space-3); }
h2 { font-size: var(--text-h2); letter-spacing: -0.01em; line-height: 1.25; margin: var(--space-7) 0 var(--space-3); }
h3 { font-size: var(--text-body); margin: var(--space-5) 0 var(--space-1); }
main p, main li { max-width: 68ch; }
.lede { font-size: var(--text-lede); color: var(--muted); margin: 0 0 var(--space-6); }
main ol, main ul { padding-left: 1.4em; }
main li { margin: var(--space-1) 0; }
main li::marker { color: var(--muted); }
code, kbd {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--raised); border-radius: 4px; padding: 0.1em 0.35em;
}
a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color var(--fast) ease; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-s); }

/* ---------- The tool panel ---------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  padding: var(--space-5);
  margin: 0 0 var(--space-6);
}
/* On wide screens the tool breaks out of the 44rem reading column so nine columns fit. */
@media (min-width: 62rem) {
  .tool { margin-inline: calc(50% - min(50vw - 32px, 38rem)); padding: var(--space-6); }
}
@media (max-width: 30rem) {
  .tool { padding: var(--space-4); margin-inline: -8px; border-radius: var(--radius-m); }
}

.sides { display: grid; gap: var(--space-5); grid-template-columns: 1fr; }
@media (min-width: 48rem) { .sides { grid-template-columns: 1fr 1fr; } }
.side { min-width: 0; }

/* Step label above each box: "1  Switch MAC address table" */
.drop { margin: 0; }
.drop span {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 650; font-size: var(--text-body); margin-bottom: var(--space-2);
}
.drop .step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; background: var(--raised); color: var(--text);
  font: 700 var(--text-xs)/1 var(--font-mono);
}
.drop textarea {
  display: block; width: 100%; height: 12rem; min-height: 6rem;
  padding: var(--space-3) var(--space-4);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--bg);
  color: var(--text);
  font: var(--text-sm)/1.55 var(--font-mono);
  tab-size: 8; white-space: pre; overflow-wrap: normal; overflow-x: auto;
  resize: vertical;
  transition: border-color var(--fast) ease, background-color var(--fast) ease;
}
.drop textarea::placeholder { color: var(--muted); opacity: 1; }
.drop textarea:hover { border-color: var(--accent); }
.drop textarea:focus-visible { outline: none; border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.drop.over textarea { border-style: solid; border-color: var(--accent); background: var(--accent-tint); }
@media (max-width: 30rem) {
  .drop textarea { height: 8rem; }
  .drop textarea:placeholder-shown { white-space: pre-wrap; overflow-wrap: anywhere; }
}

.file {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm); color: var(--muted);
}
.file input[type="file"] { font: inherit; color: var(--muted); max-width: 100%; }
.file input[type="file"]::file-selector-button {
  min-height: 44px; margin-right: var(--space-3); padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
  font: 600 var(--text-sm) var(--font-ui); cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease;
}
.file input[type="file"]::file-selector-button:hover { background: var(--raised); border-color: var(--accent); }
.file input[type="file"]::file-selector-button:active { background: var(--border); }
.file-names {
  display: block; min-height: 1.5em; margin: var(--space-2) 0 0;
  font: var(--text-sm)/1.5 var(--font-mono); color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- Buttons ---------- */
.actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  margin: var(--space-2) 0 0;
}
button { font: inherit; }
.actions button,
.primary, .secondary, .quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; min-width: 44px; padding: 0 var(--space-5);
  border-radius: var(--radius-s); border: 1px solid transparent;
  font: 650 var(--text-body)/1 var(--font-ui); cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease, transform var(--fast) ease;
}
.actions button:active, .primary:active, .secondary:active, .quiet:active { transform: translateY(1px); }

/* Primary: Join, and Download CSV once a result exists. One filled button at a time. */
.primary, #join {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  min-width: 8.5rem; box-shadow: var(--shadow-1);
}
.primary:hover, #join:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary:active, #join:active { background: var(--accent-active); }

/* Secondary: outlined. Join steps down to this once the table is on screen. */
.secondary,
.tool:has(#output table) #join {
  background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: none;
}
.secondary:hover,
.tool:has(#output table) #join:hover { background: var(--raised); border-color: var(--accent); }

/* Quiet: Clear. */
.quiet, #clear {
  background: transparent; color: var(--muted); border-color: transparent; padding: 0 var(--space-4);
}
.quiet:hover, #clear:hover { background: var(--raised); color: var(--text); }
.quiet:active, #clear:active { background: var(--border); }

button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Status line ---------- */
#status {
  min-height: 1.55em; margin: var(--space-4) 0 0;
  font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#status.busy::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--space-2);
  border-radius: 50%; background: var(--accent); vertical-align: 0.1em;
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
#status.done {
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-left: var(--edge) solid var(--success);
  background: var(--raised);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
#status.error {
  color: var(--danger);
  padding: var(--space-3) var(--space-4);
  border-left: var(--edge) solid var(--danger);
  background: var(--danger-tint);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}

/* ---------- Result ---------- */
#output:not(:empty) { margin-top: var(--space-5); animation: arrive var(--fast) ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.result-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin: 0 0 var(--space-3);
}
.result-head h2 { margin: 0; font-size: var(--text-h2); }
.legend {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  margin: 0; padding: 0; list-style: none;
  font-size: var(--text-sm); color: var(--muted);
}
.legend li { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; }
.legend li::before { content: ""; width: var(--edge); height: 14px; border-radius: 2px; background: var(--slate-edge); }
.legend .joined::before { background: var(--accent); }
.legend .no-ip::before { background: var(--warning-edge); }

.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--surface);
  max-height: 70vh; overflow-y: auto;
}
#output table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
#output th, #output td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top;
  overflow-wrap: normal;
}
#output thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--raised);
  font: 700 var(--text-xs)/1.3 var(--font-ui); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text); white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
#output tbody tr:last-child td { border-bottom: 0; }
#output tbody tr { transition: background-color var(--fast) ease; }
#output tbody tr:hover { background: var(--accent-tint); }

/* The signature: a patch-lead edge on every row, coloured by status. */
#output tbody td:first-child { box-shadow: inset var(--edge) 0 0 var(--slate-edge); padding-left: calc(var(--space-3) + var(--edge)); }
#output tbody tr[data-status="joined"] td:first-child { box-shadow: inset var(--edge) 0 0 var(--accent); }
#output tbody tr[data-status="no ip"] td:first-child { box-shadow: inset var(--edge) 0 0 var(--warning-edge); }

/* Readouts: switch, port, VLAN, MAC, IP in monospace, never wrapped. */
#output td.mono {
  font-family: var(--font-mono); font-size: 0.8125rem; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#output td.ip { white-space: normal; min-width: 9rem; }
#output td.vendor { min-width: 10rem; max-width: 18rem; }
#output td.notes, #output td.seen { color: var(--muted); min-width: 8rem; }
#output td.empty::after { content: "\2014"; color: var(--muted); }
#output td.status { white-space: nowrap; font-weight: 600; }
#output tr[data-status="joined"] td.status { color: var(--success); }
#output tr[data-status="no ip"] td.status { color: var(--warning); }
#output tr[data-status="no port"] td.status { color: var(--muted); }

.cap-note { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--muted); }

/* Lines not read / incomplete / left out */
.line-lists { margin-top: var(--space-5); display: grid; gap: var(--space-4); }
.line-list :is(h2, h3) {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm); line-height: 1.55; letter-spacing: .04em; text-transform: uppercase;
}
.line-list :is(h2, h3) .count { color: var(--muted); font-weight: 600; margin-left: var(--space-1); }
.line-list ol {
  margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  max-height: 18rem; overflow: auto;
}
.line-list li {
  display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: var(--space-1) var(--space-3);
  margin: 0; padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border); font-size: var(--text-sm); max-width: none;
}
.line-list li:last-child { border-bottom: 0; }
.line-list .where { color: var(--muted); font-variant-numeric: tabular-nums; }
.line-list .text {
  font-family: var(--font-mono); font-size: 0.8125rem;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.line-list .why { grid-column: 2; color: var(--warning); font-size: var(--text-sm); }
.line-list.unread ol { border-left: var(--edge) solid var(--warning-edge); }
@media (max-width: 30rem) {
  .line-list li { grid-template-columns: 1fr; }
  .line-list .why { grid-column: 1; }
}

.registry-date { margin: var(--space-4) 0 0; font-size: var(--text-sm); color: var(--muted); }

/* ---------- Template parts, restyled not resized ---------- */
.ad-slot { background: var(--raised); border: 1px solid var(--border); }
.ad-label { color: var(--muted); opacity: 1; }
.house-card { background: var(--surface); border: 1px solid var(--border); }
.house-card:hover { border-color: var(--accent); }
.house-card strong { color: var(--accent-text); }
.consent { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-2); }
.consent button { border-color: var(--border-strong); color: var(--text); transition: background-color var(--fast) ease; }
.consent button:hover { background: var(--raised); }
footer { border-top: 1px solid var(--border); color: var(--muted); opacity: 1; }

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