/* clickcheck styles */
:root {
  --paper:    #e8eae9;
  --surface:  #f7f8f8;
  --sunken:   #dfe2e1;
  --ink:      #16191b;
  --muted:    #5e6a6e;
  --faint:    #8b9497;
  --rule:     #c8cfce;
  --rule-soft:#d8dddc;

  --safe:      #0f6e4a;
  --suspicious:#9a6200;
  --dangerous: #ad2117;

  --safe-wash:      #dfeee7;
  --suspicious-wash:#f4e8d2;
  --dangerous-wash: #f4dedc;

  --focus: #16191b;

  --step: 0.35rem;
  --col: 68rem;

  font-size: 16px;
}

/* dark mode  */
[data-theme="dark"] {
  --paper:    #111314;
  --surface:  #191c1d;
  --sunken:   #0b0d0e;
  --ink:      #e9ebea;
  --muted:    #98a2a5;
  --faint:    #6d7679;
  --rule:     #2b3032;
  --rule-soft:#222627;

  --safe:      #46c48c;
  --suspicious:#e0a63a;
  --dangerous: #f2705f;

  --safe-wash:      #12271f;
  --suspicious-wash:#2a2113;
  --dangerous-wash: #2c1715;

  --focus: #e9ebea;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* script.js hides things with .hidden = true, so this has to beat
   the display rules further down or nothing would ever hide */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* small label above each section */
.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: calc(var(--step) * 2);
}

/* top bar with the logo */

.site-header {
  width: min(var(--col), 90%);
  margin: 0 auto;
  padding: 1.8rem 0 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-mark { width: 26px; height: 26px; color: var(--ink); }

.brand-name {
  font-family: "Archivo", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.035em;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; }

/* moon when the page is light, sun when it is dark */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

main {
  width: min(var(--col), 90%);
  margin: 0 auto;
  flex: 1;
  padding-bottom: 4rem;
}

/* the scan box */

.scanner {
  padding: 3.2rem 0 2.4rem;
}

.scanner-label {
  font-family: "Archivo", sans-serif;
  font-weight: 600;
  font-size: clamp(1.7rem, 4.2vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  max-width: 22ch;
  margin-bottom: 1.6rem;
}
.scanner-label label { cursor: pointer; }

/* highlight behind the word "before" */
.scanner-label em {
  font-style: normal;
  box-shadow: inset 0 -0.34em 0 var(--sunken);
}

.scanner-bar {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
  max-width: 44rem;
}

#url-input {
  flex: 1;
  min-width: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  padding: 0.95rem 1rem;
  border: 0;
  background: transparent;
  color: var(--ink);
}
#url-input::placeholder { color: var(--faint); }
#url-input:focus { outline: none; }
.scanner-bar:focus-within { box-shadow: 0 0 0 3px var(--sunken); }

#scan-btn {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0 1.5rem;
  border: 0;
  border-left: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}
#scan-btn:hover:not(:disabled) { opacity: 0.82; }
#scan-btn:disabled { opacity: 0.5; cursor: progress; }

.scanner-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 52ch;
}

/* error message under the input */
.form-error {
  margin-top: 0.9rem;
  padding: 0.6rem 0.85rem;
  border-left: 3px solid var(--dangerous);
  background: var(--dangerous-wash);
  color: var(--dangerous);
  font-size: 0.87rem;
  font-weight: 500;
}

/* result card. the thick left border is the verdict colour, so you
   can tell safe from dangerous without reading anything */

.verdict {
  --vc: var(--muted);
  --vwash: var(--sunken);
  display: block;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 5px solid var(--vc);
  border-radius: 2px;
  padding: 1.8rem;
  margin-bottom: 3rem;
  animation: rise 0.25s ease-out;
}

/* script.js puts safe / suspicious / dangerous on the section */
.verdict.safe       { --vc: var(--safe);       --vwash: var(--safe-wash); }
.verdict.suspicious { --vc: var(--suspicious); --vwash: var(--suspicious-wash); }
.verdict.dangerous  { --vc: var(--dangerous);  --vwash: var(--dangerous-wash); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.verdict-inner {
  display: flex;
  align-items: flex-start;
  gap: 1.8rem;
  flex-wrap: wrap;
}

/* the score circle. script.js sets --pct on it inline */
.score-dial {
  --pct: 0;
  position: relative;
  flex: none;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(
    var(--vc) calc(var(--pct) * 1%),
    var(--rule-soft) 0
  );
}
/* tick marks around the ring */
.score-dial::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
    var(--surface) 0deg 1.2deg,
    transparent 1.2deg 9deg
  );
}
/* hole in the middle so it reads as a ring */
.score-dial::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: var(--surface);
}

.dial-center {
  position: relative;
  z-index: 1;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--vc);
}

.verdict-text { flex: 1; min-width: 15rem; }

.verdict-title {
  font-family: "Archivo", sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--vc);
  margin-bottom: 0.4rem;
}

.verdict-url {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule-soft);
}

/* the one line per api */
.verdict-detail { list-style: none; }
.verdict-detail li {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.28rem 0 0.28rem 1rem;
  position: relative;
}
.verdict-detail li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85em;
  width: 5px;
  height: 1px;
  background: var(--faint);
}

.verdict-advice {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  background: var(--vwash);
  border-radius: 2px;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* past scans table */

.history { border-top: 1px solid var(--rule); padding-top: 2.4rem; }

.history-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.history-head h2 {
  font-family: "Archivo", sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.ghost-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
/* goes red on hover since it deletes things */
.ghost-btn:hover { color: var(--dangerous); border-color: var(--dangerous); }

/* search / filter / sort row */
.history-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

#history-search {
  flex: 1;
  min-width: 12rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
}
#history-search::placeholder { color: var(--faint); }

#history-filter, #history-sort {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.table-wrap {
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
  overflow-x: auto;
}

#history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#history-table th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

#history-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
#history-table tr:last-child td { border-bottom: 0; }
#history-table tbody tr:hover { background: var(--paper); }

/* monospace so a fake domain is easier to spot */
.url-cell {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  max-width: 26rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* risk and date columns are numbers too */
#history-table td:nth-child(3),
#history-table td:nth-child(4) {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* the little safe / suspicious / dangerous tag */
.badge {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.badge.safe       { color: var(--safe);       background: var(--safe-wash); }
.badge.suspicious { color: var(--suspicious); background: var(--suspicious-wash); }
.badge.dangerous  { color: var(--dangerous);  background: var(--dangerous-wash); }

.history-empty {
  padding: 2.2rem 1rem;
  text-align: center;
  color: var(--faint);
  font-size: 0.87rem;
}

/* footer */

.site-footer {
  width: min(var(--col), 90%);
  margin: 0 auto;
  padding: 1.6rem 0 2.4rem;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.credits {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 58ch;
}
.credits a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.credits a:hover { border-bottom-color: var(--ink); }

/* shows which of my two web servers answered the request */
.served-by {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--faint);
  white-space: nowrap;
}
/* only draw the dot once there is text in there */
.served-by:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--safe);
  margin-right: 0.45rem;
  vertical-align: middle;
}

/* phones */

@media (max-width: 34rem) {
  .scanner { padding-top: 2.2rem; }
  .scanner-bar { flex-direction: column; }
  #scan-btn {
    border-left: 0;
    border-top: 1.5px solid var(--ink);
    padding: 0.85rem 1rem;
  }
  .verdict { padding: 1.3rem; }
  .verdict-inner { gap: 1.2rem; }
  .score-dial { width: 84px; height: 84px; }
  .dial-center { font-size: 1.45rem; }
  .history-head { flex-direction: column; align-items: flex-start; }
  .url-cell { max-width: 13rem; }
}

/* for people who turn animations off */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
