@import url('fonts.css');

:root {
  --maroon: #4A0C16;
  --black: #120A0D;
  --accent: #DD3251;
  --accent-2: #e84a67;
  --text: #FAFCFC;
  --muted: #8A6E73;
  --success: #32E08D;
  --border: rgba(221, 50, 81, 0.22);
  --panel: rgba(18, 10, 13, 0.72);
  --panel-solid: #1a0e12;
  --field: #0d0609;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --maxw: 1040px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, #5a0f1c 0%, transparent 55%),
              linear-gradient(160deg, var(--maroon) 0%, var(--black) 60%, #000 100%);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Accessible focus states */
a:focus-visible, button:focus-visible, input:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------------- Entrance motion ---------------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.reveal { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; }
.reveal.d1 { animation-delay: .06s; }
.reveal.d2 { animation-delay: .12s; }
.reveal.d3 { animation-delay: .18s; }
.grid .chal-card:nth-child(1) { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .05s; }
.grid .chal-card:nth-child(2) { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .13s; }
.grid .chal-card:nth-child(3) { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .21s; }

.cursor {
  display: inline-block; width: 9px; height: 1.05em; margin-left: 2px;
  background: var(--success); vertical-align: -2px; animation: blink 1.1s step-end infinite;
}

/* ---------------- Header / nav ---------------- */
header.site {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(18, 10, 13, 0.82);
  border-bottom: 1px solid var(--border);
}
header.site .bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; max-width: var(--maxw); margin: 0 auto; gap: 16px;
}
.brand {
  font-family: 'Archivo Black', sans-serif;
  letter-spacing: 1px; font-size: 18px; color: var(--text);
  display: flex; align-items: center; gap: 2px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--accent); }
nav.site { display: flex; flex-wrap: wrap; }
nav.site a {
  color: var(--muted); margin-left: 18px; font-size: 14px; font-weight: 500;
  text-decoration: none; transition: color .15s ease; position: relative;
}
nav.site a::after {
  content: ""; position: absolute; left: 0; bottom: -4px; height: 2px; width: 0;
  background: var(--accent); transition: width .2s ease;
}
nav.site a:hover { color: var(--text); text-decoration: none; }
nav.site a.active { color: var(--text); }
nav.site a.active::after { width: 100%; }

@media (max-width: 620px) {
  header.site .bar { flex-direction: column; gap: 10px; }
  nav.site { justify-content: center; }
  nav.site a { margin: 0 9px; }
}

/* ---------------- Hero / glitch wordmark ---------------- */
.hero { padding: 86px 0 54px; text-align: center; position: relative; }
.hero .kicker {
  font-family: var(--mono); color: var(--accent); letter-spacing: 3px;
  font-size: 13px; text-transform: uppercase; margin-bottom: 22px;
}
.glitch {
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(38px, 9vw, 86px);
  line-height: 1.02; letter-spacing: 1px; margin: 0;
  position: relative; display: inline-block; color: var(--text);
  text-shadow: 0 0 22px rgba(221, 50, 81, 0.25);
}
.glitch .slash { color: var(--accent); }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0; pointer-events: none; clip-path: inset(0 0 0 0);
}
.glitch::before { left: 2px; text-shadow: -2px 0 #00e5ff; animation: glitch-x 2.6s infinite linear alternate-reverse; }
.glitch::after  { left: -2px; text-shadow: -2px 0 var(--accent); animation: glitch-y 1.9s infinite linear alternate-reverse; }
@keyframes glitch-x {
  0% { clip-path: inset(2% 0 92% 0); } 20% { clip-path: inset(40% 0 40% 0); }
  40% { clip-path: inset(80% 0 2% 0); } 60% { clip-path: inset(10% 0 70% 0); }
  80% { clip-path: inset(55% 0 20% 0); } 100% { clip-path: inset(30% 0 50% 0); }
}
@keyframes glitch-y {
  0% { clip-path: inset(70% 0 10% 0); } 25% { clip-path: inset(20% 0 60% 0); }
  50% { clip-path: inset(50% 0 30% 0); } 75% { clip-path: inset(5% 0 85% 0); }
  100% { clip-path: inset(60% 0 15% 0); }
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.04) 1px, transparent 2px, transparent 4px);
  mix-blend-mode: overlay; opacity: 0.6;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-block; font-weight: 600; font-size: 14px;
  padding: 11px 20px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 24px rgba(221,50,81,0.32); }
.btn-primary:hover { background: var(--accent-2); box-shadow: 0 10px 30px rgba(221,50,81,0.45); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }

/* ---------------- Sections / panels / cards ---------------- */
section.block { padding: 30px 0; }
h2.section-title { font-family: 'Archivo Black', sans-serif; font-size: 22px; margin: 0 0 6px; }
.section-sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.panel + .panel { margin-top: 20px; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.chal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease;
}
.chal-card:hover {
  transform: translateY(-4px); border-color: var(--accent);
  box-shadow: 0 16px 44px rgba(0,0,0,0.5), 0 0 0 1px rgba(221,50,81,0.25);
}
.chal-card .num { font-family: var(--mono); color: var(--accent); font-size: 12px; }
.chal-card .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.chal-card h3 { font-family: 'Archivo Black', sans-serif; font-size: 18px; margin: 4px 0 0; }
.chal-card p.brief { color: var(--muted); font-size: 14px; flex: 1; margin: 0; }
.chal-card .btn { margin-top: 4px; }

/* ---------------- Chips / badges ---------------- */
.chip {
  font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.chip.cat { color: #ffd9e0; border-color: rgba(221,50,81,0.4); }
.chip.easy { color: var(--success); border-color: rgba(50,224,141,0.4); }
.chip.medium { color: #ffcf6b; border-color: rgba(255,207,107,0.4); }
.chip.hard { color: #ff8a6b; border-color: rgba(255,138,107,0.4); }

/* ---------------- Forms / tables / code ---------------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=password] {
  width: 100%; padding: 11px 13px; border-radius: 9px; font-size: 14px;
  background: var(--field); color: var(--text); border: 1px solid var(--border);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: #6b5257; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(221,50,81,0.18); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: .5px; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(221,50,81,0.06); }

code { font-family: var(--mono); font-size: 13px; color: #ffd9e0;
  background: rgba(221,50,81,0.12); padding: 2px 6px; border-radius: 6px; }
pre {
  font-family: var(--mono); font-size: 13px; background: #0b0508; color: #e8edf0;
  padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border);
  overflow-x: auto; margin: 12px 0;
}

.alert { padding: 11px 14px; border-radius: 9px; font-size: 14px; margin: 10px 0; }
.alert-err { background: rgba(221,50,81,0.12); color: #ffb3c0; border: 1px solid rgba(221,50,81,0.4); }

.flag-box {
  background: rgba(50,224,141,0.1); border: 1px solid rgba(50,224,141,0.5);
  color: var(--success); font-family: var(--mono); font-size: 16px; font-weight: 600;
  padding: 16px; border-radius: 10px; margin: 0 0 20px; word-break: break-all;
  animation: fade .4s ease both;
}

.review { padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); }

/* ---------------- Challenge page head ---------------- */
.page-head { margin: 10px 0 10px; }
.page-head .num { font-family: var(--mono); color: var(--accent); font-size: 12px; }
.page-head h1 { font-family: 'Archivo Black', sans-serif; font-size: 30px; margin: 8px 0 6px; }
.page-head .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.back-link { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.back-link:hover { color: var(--text); }

/* ---------------- 404 ---------------- */
.notfound { text-align: center; padding: 100px 0 80px; }
.notfound .glitch { font-size: clamp(64px, 16vw, 140px); }
.notfound p { color: var(--muted); margin: 18px 0 26px; font-size: 16px; }

/* ---------------- Footer ---------------- */
footer.site {
  border-top: 1px solid var(--border); margin-top: 50px; padding: 26px 0;
  color: var(--muted); font-size: 13px; text-align: center;
}
.prompt { font-family: var(--mono); color: var(--success); font-size: 13px; }

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .glitch::before, .glitch::after { animation: none; }
  .cursor { animation: none; opacity: 1; }
}
