/* Safe Tayo? CTF. Palette, type and header follow safetayo.ph; light by default, dark by device or toggle. */
@font-face { font-family: "Bricolage Grotesque"; src: url(/brand/fonts/bricolage-grotesque-latin-wght-normal.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(/brand/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(/brand/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  /* Brand tokens, same values as safetayo.ph. */
  --paper: #F1F4F9; --page: #FFFFFF; --ink: #14223F; --muted: #566579; --rule: #CBD6E6;
  --head: #D6E6FA; --accent: #1F4E9E; --hilite: #FFE36B; --hilite-ink: #14223F; --btn: #1F4E9E; --btn-ink: #F1F4F9; --focus: #1A5FD1;
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* CTF additions, kept within the brand's blues plus one red for wrong answers. */
  --code-bg: #E8EEF7; --bad: #B42318; --bad-bg: #FDECEA; --info-bg: #E3EDFB; --solved-bg: #FFF8D6;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C1424; --page: #131D31; --ink: #E4EAF3; --muted: #97A3B6; --rule: #24324A;
    --head: #000000; --accent: #8DB6FF; --hilite: #E9CB3E; --hilite-ink: #111A2B; --btn: #8DB6FF; --btn-ink: #0C1424; --focus: #7DB0FF;
    --code-bg: #0F1828; --bad: #FF9B8F; --bad-bg: #2A1618; --info-bg: #14233D; --solved-bg: #1E2230;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C1424; --page: #131D31; --ink: #E4EAF3; --muted: #97A3B6; --rule: #24324A;
  --head: #000000; --accent: #8DB6FF; --hilite: #E9CB3E; --hilite-ink: #111A2B; --btn: #8DB6FF; --btn-ink: #0C1424; --focus: #7DB0FF;
  --code-bg: #0F1828; --bad: #FF9B8F; --bad-bg: #2A1618; --info-bg: #14233D; --solved-bg: #1E2230;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 1.0625rem; line-height: 1.6; overflow-wrap: break-word;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 0.5rem; overflow-wrap: break-word; text-wrap: balance; }
h1 { font-weight: 800; font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); }
h2 { font-weight: 800; font-size: 1.35rem; }
h3 { font-weight: 700; font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--code-bg); border: 1px solid var(--rule); border-radius: 5px; padding: 0.05em 0.35em; }
code.wrap { word-break: break-all; }
small { color: var(--muted); font-size: 0.88rem; display: block; margin-top: 0.25rem; font-weight: 400; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--page); color: var(--ink); padding: 8px 12px; border-radius: 6px; z-index: 20; }
.skip:focus { left: 12px; }
.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; }
.muted { color: var(--muted); }
.empty { color: var(--muted); background: var(--page); border: 1px dashed var(--rule); border-radius: var(--radius); padding: 1.5rem; text-align: center; }

/* ---------- header: light-blue band with the yellow rule, like safetayo.ph ---------- */
.topbar { background: var(--head); border-bottom: 6px solid var(--hilite); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.mark { display: block; height: 28px; width: auto; }
.ctf-tag {
  font-family: var(--display); font-weight: 800; font-size: 1rem; letter-spacing: 0.06em; line-height: 1;
  background: var(--hilite); color: var(--hilite-ink); border-radius: 4px; padding: 0.3em 0.45em 0.25em;
}
.headright { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topnav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topnav a, .navbtn { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 0.95rem; padding: 4px 2px; }
.topnav a:hover, .navbtn:hover { text-decoration: underline; }
.topnav form { margin: 0; }
.navbtn { background: none; border: 0; font-family: inherit; cursor: pointer; min-height: 0; }
.who { color: var(--muted); font-size: 0.95rem; }
.themebtn {
  position: relative; width: 36px; height: 36px; border-radius: 50%; flex: none; padding: 0; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--ink) 45%, transparent); background: transparent; color: var(--ink);
  display: inline-grid; place-items: center;
}
.themebtn::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; }
.themebtn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.themebtn svg { width: 18px; height: 18px; }

.container { flex: 1; padding-block: 2rem 4rem; }
.crumbs { font-size: 0.95rem; margin-bottom: 0.5rem; }
.crumbs a { font-weight: 700; }
.section-label { font-family: var(--body); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 2rem 0 0.75rem; }

.sitefoot { padding-block: 28px 40px; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--rule); text-align: center; }
.sitefoot a { color: inherit; font-weight: 700; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--rule); margin: 1rem 0 1.5rem; overflow-x: auto; }
.tabs a { color: var(--muted); padding: 0.6rem 0.9rem; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 700; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- cards ---------- */
.card { background: var(--page); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.narrow { max-width: 440px; margin: 2.5rem auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px; }
.grid .card { margin: 0; }
a.card { color: var(--ink); display: block; text-decoration: none; transition: border-color 120ms ease, box-shadow 120ms ease; }
a.card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.event-card h3 { margin-top: 0.7rem; font-size: 1.3rem; }
.event-card p { margin: 0; font-size: 0.95rem; }

.chal-card { min-height: 136px; display: flex; flex-direction: column; }
.chal-card h3 { margin: 0.55rem 0 0.25rem; }
.chal-card p { margin: auto 0 0; font-size: 0.92rem; }
.chal-top { display: flex; align-items: center; gap: 0.5rem; }
.chal-card.solved { background: var(--solved-bg); border-color: color-mix(in srgb, var(--hilite) 70%, var(--rule)); }
.points { font-family: var(--display); font-weight: 800; color: var(--accent); font-size: 1.15rem; line-height: 1; }
.tick { margin-left: auto; font-size: 0.82rem; font-weight: 700; background: var(--hilite); color: var(--hilite-ink); border-radius: 999px; padding: 0.15rem 0.6rem; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 700; color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 999px; padding: 0.15rem 0.7rem; }

/* ---------- event + challenge headers ---------- */
.eventbar { display: flex; flex-direction: column; gap: 0.15rem; }
.eventbar h1 { margin: 0; }
.eventbar p { margin: 0; }
.chal-head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.chal-head h1 { margin: 0; }
.chal-head .points { margin-left: auto; font-size: 1.35rem; }

.prose { max-width: 66ch; }
.prose p:last-child { margin-bottom: 0; }
.prose pre { background: var(--code-bg); border: 1px solid var(--rule); border-radius: 8px; padding: 0.75rem; overflow-x: auto; }
.prose pre code { border: 0; padding: 0; background: none; }
.format { margin: 1rem 0; color: var(--muted); }

/* ---------- challenge file viewer ---------- */
.file-view { padding: 0; overflow: hidden; }
.file-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.7rem 1rem; border-bottom: 1px solid var(--rule); background: var(--head); }
.file-head h3 { margin: 0; font-family: var(--body); }
.file-head code { background: none; border: 0; padding: 0; font-weight: 700; }
.file-download { font-size: 0.92rem; font-weight: 700; }
.file-view > p { margin: 0; padding: 1rem; }
.file-view pre {
  margin: 0; padding: 1rem; max-height: 28rem; overflow: auto; background: var(--code-bg); color: var(--ink);
  font: 0.85rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
}
.file-view img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.file-view iframe { display: block; width: 100%; height: 26rem; border: 0; background: #fff; }
.file-view details { border-top: 1px solid var(--rule); }
.file-view summary { cursor: pointer; padding: 0.75rem 1rem; font-weight: 700; color: var(--accent); min-height: 44px; }
.file-view details pre { border-top: 1px solid var(--rule); }

/* ---------- flag input ---------- */
.flag-form { display: flex; align-items: center; gap: 0.5rem; background: var(--page); border: 2px solid var(--rule); border-radius: var(--radius); padding: 0.35rem 0.35rem 0.35rem 1rem; margin: 1.25rem 0; max-width: 640px; }
.flag-form:focus-within { border-color: var(--focus); }
.flag-form input { flex: 1; min-width: 0; background: none; border: 0; padding: 0.55rem 0; font-family: var(--mono); color: var(--ink); font-size: 1rem; box-shadow: none; }
.flag-form input:focus { outline: none; box-shadow: none; }
.flag-form button { width: 2.9rem; height: 2.9rem; padding: 0; font-size: 1.2rem; flex: none; }

.hints .card h3 { margin-bottom: 0.4rem; }
.hint.locked { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.hint.locked h3, .hint.locked p, .hint.locked form { margin: 0; }
.hint-admin { border-top: 1px solid var(--rule); padding-top: 1rem; }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack > * { margin: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 1rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 700; font-size: 0.97rem; }
label.check { flex-direction: row; align-items: center; gap: 0.6rem; font-weight: 400; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--page); border: 1px solid color-mix(in srgb, var(--ink) 35%, var(--rule)); border-radius: 6px;
  padding: 0.6rem 0.75rem; width: 100%; min-height: 44px;
}
input[type="checkbox"] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--accent); flex: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input:disabled { opacity: 0.6; }

/* Buttons follow the site's .btn: solid brand blue, or outlined ink for secondary. */
button, .button {
  font: inherit; font-weight: 700; font-size: 0.97rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; line-height: 1.3; padding: 0.55em 1.1em; border-radius: 6px; text-decoration: none;
  color: var(--ink); background: transparent; border: 2px solid var(--ink);
}
button:hover, .button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.primary:hover { background: var(--btn); filter: brightness(1.12); }
.danger { color: var(--bad); border-color: var(--bad); }
.danger:hover { background: var(--bad-bg); }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }
.stack > button, .stack > .button { align-self: flex-start; }
form.inline { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; }
form.inline select { width: auto; min-height: 36px; padding: 0.3rem 0.5rem; }
form.inline button, .row-actions button { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.88rem; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { margin: 0; }
.filters { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { flex: 1 1 160px; }

/* ---------- messages ---------- */
.flash { border-radius: 8px; padding: 0.75rem 1rem; margin: 0.9rem 0; border: 1px solid; font-weight: 700; }
.flash p { margin: 0.15rem 0; }
.flash-ok { background: var(--hilite); color: var(--hilite-ink); border-color: var(--hilite); }
.flash-bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.flash-info { background: var(--info-bg); color: var(--ink); border-color: var(--rule); font-weight: 400; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.97rem; background: var(--page); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.table th, .table td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; background: var(--paper); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.scoreboard td:first-child { font-family: var(--display); font-weight: 800; }
.scoreboard tbody tr:nth-child(-n + 3) td:first-child { color: var(--hilite-ink); }
.scoreboard tbody tr:nth-child(-n + 3) td:first-child::before {
  content: ""; display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--hilite); margin-right: 0.45em; vertical-align: 0.05em;
}
:root[data-theme="dark"] .scoreboard tbody tr:nth-child(-n + 3) td:first-child { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .scoreboard tbody tr:nth-child(-n + 3) td:first-child { color: var(--ink); } }
.scoreboard tr.me td { background: var(--solved-bg); font-weight: 700; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }

/* Phones: wordmark and theme button share the top row; links sit below as boxes, like safetayo.ph. */
@media (max-width: 640px) {
  .topbar-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; padding-block: 12px 8px; }
  .brand { grid-area: 1 / 1; }
  .mark { height: 22px; }
  .headright { display: contents; }
  .themebtn { grid-area: 1 / 2; }
  .topnav { grid-area: 2 / 1 / 3 / 3; display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5em, 1fr)); gap: 8px; }
  .topnav a, .navbtn {
    width: 100%; padding: 8px 10px; min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center;
    background: var(--page); border: 1px solid var(--rule); border-radius: 8px; color: var(--ink);
  }
  .topnav a:hover, .navbtn:hover { text-decoration: none; border-color: var(--ink); }
  .who { display: none; }
  .container { padding-top: 1.4rem; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .chal-head .points { margin-left: 0; }
}

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