/* ==========================================================================
   Detour — error page pack (404 x4, 500, maintenance)
   Theme tokens: override these to recolour every page at once.
   Each page adds a body class (.p-minimal, .p-illustrated, …) that may
   locally adjust the tokens.
   ========================================================================== */
:root {
  --brand: #4f46e5;
  --accent: #f97362;
  --accent-2: #22c3a6;
  --sun: #ffc745;
  --bg: #ffffff;
  --surface: #f5f5f8;
  --text: #16161d;
  --muted: #5c5c6e;
  --line: #e4e4ec;
  --radius: 14px;
  --font-display: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 400 17px/1.6 var(--font-body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; }
svg { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 .4em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 8px; }
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 50; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shared chrome */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px clamp(20px, 5vw, 48px); }
.logo { display: inline-flex; align-items: center; gap: 10px; font: 700 1.25rem var(--font-display); text-decoration: none; letter-spacing: -.02em; }
.logo svg { width: 30px; height: 30px; }
.bar nav { display: flex; gap: 22px; font-size: .95rem; }
.bar nav a { text-decoration: none; color: var(--muted); }
.bar nav a:hover { color: var(--text); }
@media (max-width: 520px) { .bar nav { display: none; } }
main { flex: 1; display: grid; place-items: center; padding: 24px clamp(20px, 5vw, 48px) 48px; }
.foot { padding: 20px clamp(20px, 5vw, 48px) 28px; font-size: .85rem; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot a { color: inherit; }
.code { display: inline-block; font: 600 .8rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); margin-bottom: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 22px; border-radius: 12px; font: 600 .98rem var(--font-body); text-decoration: none; border: 1.5px solid transparent; cursor: pointer; transition: transform .2s, background .2s, border-color .2s, color .2s; }
.btn:hover { transform: translateY(-2px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 85%, #000); }
.btn-ghost { border-color: var(--line); background: var(--bg); color: var(--text); }
.btn-ghost:hover { border-color: var(--text); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.center { text-align: center; }
.center .actions { justify-content: center; }

.search { display: flex; max-width: 440px; border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--bg); transition: border-color .2s, box-shadow .2s; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.search input { flex: 1; min-width: 0; border: 0; padding: 13px 16px; font: inherit; background: transparent; color: var(--text); }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--muted); }
.search button { border: 0; background: transparent; padding: 0 16px; cursor: pointer; color: var(--muted); }
.search button:hover { color: var(--brand); }
.search button svg { width: 20px; height: 20px; }
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .95rem; }
.links a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.links a:hover { text-decoration-thickness: 2px; }

/* ---------- 404 minimal ---------- */
.p-minimal .wrap { max-width: 640px; width: 100%; }
.p-minimal .big { font: 200 clamp(7rem, 26vw, 15rem)/.85 var(--font-display); letter-spacing: -.06em; margin: 0 0 18px; display: flex; align-items: baseline; gap: .02em; }
.p-minimal .big .o { display: inline-block; width: .62em; height: .62em; border-radius: 50%; border: .045em solid var(--text); position: relative; transform: translateY(-.02em); }
.p-minimal .big .o::after { content: ""; position: absolute; width: .14em; height: .14em; border-radius: 50%; background: var(--accent); top: 22%; left: 22%; animation: orbit 6s linear infinite; transform-origin: .17em .17em; }
@keyframes orbit { to { transform: rotate(360deg); } }
.p-minimal h1 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); font-weight: 600; }
.p-minimal .wrap > p:not(.big) { color: var(--muted); font-size: 1.1rem; max-width: 480px; }
.p-minimal .search { margin: 28px 0 22px; }
.p-minimal .rule { height: 1px; background: var(--line); margin: 32px 0 20px; }
.p-minimal .links-title { font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

/* ---------- 404 illustrated ---------- */
.p-illustrated { --bg: #fdf6ec; --surface: #fff; --line: #eadcc8; --brand: #3f37c9; }
.p-illustrated .grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(28px, 5vw, 70px); align-items: center; max-width: 1140px; width: 100%; }
.p-illustrated .scene { width: 100%; height: auto; }
.p-illustrated h1 { font-size: clamp(2.3rem, 5vw, 3.8rem); font-weight: 800; }
.p-illustrated .copy > p { color: var(--muted); font-size: 1.12rem; max-width: 460px; }
.p-illustrated .actions { margin: 28px 0 30px; }
.p-illustrated .suggest { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; max-width: 460px; }
.p-illustrated .suggest b { display: block; margin-bottom: 8px; }
.scene .bird { animation: fly 9s ease-in-out infinite; }
.scene .bird.b2 { animation-delay: -4s; animation-duration: 11s; }
@keyframes fly { 50% { transform: translate(-30px, -12px); } }
.scene .cloud { animation: float 14s ease-in-out infinite alternate; }
@keyframes float { to { transform: translateX(26px); } }
.scene .hiker { animation: look 4s ease-in-out infinite; transform-origin: 330px 360px; transform-box: view-box; }
@keyframes look { 0%, 60%, 100% { transform: none; } 70%, 90% { transform: scaleX(-1); } }
@media (max-width: 860px) { .p-illustrated .grid { grid-template-columns: 1fr; text-align: center; } .p-illustrated .copy > p, .p-illustrated .suggest { margin-inline: auto; } .p-illustrated .actions, .p-illustrated .links { justify-content: center; } .p-illustrated .scene { max-width: 520px; margin: 0 auto; } }

/* ---------- 404 playful (mini game) ---------- */
.p-playful { --bg: #fff4d6; --brand: #6d28d9; --line: #f1dca1; --surface: #fffbef; }
.p-playful .wrap { width: 100%; max-width: 900px; text-align: center; }
.p-playful h1 { font-size: clamp(2.2rem, 5.6vw, 4rem); font-weight: 800; }
.p-playful h1 span { color: var(--brand); }
.p-playful .wrap > p { color: var(--muted); font-size: 1.1rem; max-width: 560px; margin: 0 auto 26px; }
.arena { position: relative; height: clamp(260px, 44vh, 380px); border-radius: 26px; background: var(--surface); border: 2.5px dashed var(--line); overflow: hidden; margin-bottom: 22px; touch-action: manipulation;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 10%, transparent) 1px, transparent 0); background-size: 22px 22px; }
.arena .digits { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4vw; font: 900 clamp(7rem, 22vw, 14rem)/1 var(--font-display); color: color-mix(in srgb, var(--brand) 14%, transparent); user-select: none; pointer-events: none; letter-spacing: -.04em; }
.arena .digits i { font-style: normal; width: .62em; display: inline-block; }
.target { position: absolute; left: 0; top: 0; width: 84px; height: 84px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: var(--brand); color: #fff; font: 900 2.6rem/1 var(--font-display); display: grid; place-items: center; box-shadow: 0 10px 0 -2px color-mix(in srgb, var(--brand) 60%, #000), 0 18px 30px -10px color-mix(in srgb, var(--brand) 70%, transparent); transition: background .2s; will-change: transform; }
.target .eyes { position: absolute; top: 24px; display: flex; gap: 14px; }
.target .eyes i { width: 10px; height: 14px; border-radius: 50%; background: #fff; display: block; position: relative; }
.target .eyes i::after { content: ""; position: absolute; width: 5px; height: 6px; border-radius: 50%; background: #1b1340; bottom: 2px; left: 3px; }
.target .mouth { position: absolute; bottom: 20px; width: 18px; height: 9px; border-radius: 0 0 18px 18px; background: #fff; }
.target:hover { background: color-mix(in srgb, var(--brand) 85%, #fff); }
.target.hit { animation: squish .3s ease; }
@keyframes squish { 40% { scale: 1.25 .8; } }
.pop { position: absolute; font: 800 1.3rem var(--font-display); color: var(--accent); pointer-events: none; animation: rise .8s ease forwards; }
@keyframes rise { to { transform: translateY(-50px); opacity: 0; } }
.hud { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.hud .pill { background: var(--text); color: var(--bg); border-radius: 999px; padding: 8px 18px; font: 700 .95rem var(--font-display); font-variant-numeric: tabular-nums; }
.hud .pill.light { background: var(--surface); color: var(--text); border: 1.5px solid var(--line); }
.hud button { font: 600 .9rem var(--font-body); background: none; border: 1.5px solid var(--text); border-radius: 999px; padding: 7px 16px; cursor: pointer; color: var(--text); }
.hud button:hover { background: var(--text); color: var(--bg); }
.no-js-note { color: var(--muted); font-size: .9rem; }
.js .no-js-note { display: none; }

/* ---------- 404 dark (glitch + terminal) ---------- */
.p-dark { --bg: #07070c; --surface: #11111a; --text: #e9e9f2; --muted: #9a9ab2; --line: #24243a; --brand: #7cf4c6; --accent: #ff4f8b; }
.p-dark .btn-primary { color: #06120d; }
.p-dark .btn-primary:hover { background: #a6f9da; }
.p-dark .btn-ghost { background: transparent; }
.p-dark .bg-grid { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 50% at 50% 40%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 70%),
              linear-gradient(transparent 0 calc(100% - 1px), var(--line) 0) 0 0 / 100% 48px,
              linear-gradient(90deg, transparent 0 calc(100% - 1px), var(--line) 0) 0 0 / 48px 100%;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 40%, transparent 85%); -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 40%, transparent 85%); }
.p-dark .scan { position: fixed; inset: 0; pointer-events: none; z-index: 5; background: repeating-linear-gradient(transparent 0 2px, rgba(255,255,255,.025) 2px 3px); }
.p-dark .wrap { width: 100%; max-width: 760px; text-align: center; }
.glitch { position: relative; display: inline-block; font: 800 clamp(7rem, 24vw, 14rem)/.9 var(--font-display); letter-spacing: -.05em; margin: 0 0 10px; color: var(--text); }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; }
.glitch::before { color: var(--accent); animation: g1 2.8s infinite steps(1); mix-blend-mode: screen; }
.glitch::after { color: var(--brand); animation: g2 3.2s infinite steps(1); mix-blend-mode: screen; }
@keyframes g1 { 0%, 86%, 100% { transform: none; clip-path: none; opacity: 0; } 88% { transform: translate(-6px, 2px); clip-path: inset(10% 0 55% 0); opacity: 1; } 92% { transform: translate(5px, -2px); clip-path: inset(60% 0 8% 0); opacity: 1; } 95% { transform: translate(-3px, 0); clip-path: inset(35% 0 40% 0); opacity: 1; } }
@keyframes g2 { 0%, 80%, 100% { transform: none; clip-path: none; opacity: 0; } 82% { transform: translate(6px, -1px); clip-path: inset(50% 0 20% 0); opacity: 1; } 86% { transform: translate(-5px, 2px); clip-path: inset(15% 0 70% 0); opacity: 1; } }
.p-dark h1 { font-size: clamp(1.6rem, 3.6vw, 2.3rem); font-weight: 600; }
.p-dark .wrap > p:not(.glitch) { color: var(--muted); font-size: 1.08rem; max-width: 520px; margin: 0 auto 30px; }
.terminal { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin: 0 auto 32px; max-width: 620px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.8); }
.terminal .tbar { display: flex; gap: 7px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.terminal .tbar i { width: 11px; height: 11px; border-radius: 50%; background: #2c2c40; }
.terminal .tbar span { margin-left: 10px; font: 500 .75rem var(--font-mono); color: var(--muted); }
.terminal pre { margin: 0; padding: 18px 20px 22px; font: 400 .86rem/1.8 var(--font-mono); color: #c9c9da; white-space: pre-wrap; word-break: break-word; min-height: 190px; }
.terminal .ok { color: var(--brand); } .terminal .err { color: var(--accent); } .terminal .dim { color: #6d6d88; }
.cursor { display: inline-block; width: .6em; height: 1.1em; background: var(--brand); vertical-align: text-bottom; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.p-dark .foot { color: #7a7a94; }

/* ---------- 500 ---------- */
.p-500 { --bg: #f7f7fb; --brand: #c73a22; --surface: #fff; }
.p-500 .card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: clamp(28px, 5vw, 56px); max-width: 980px; width: 100%; display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(24px, 5vw, 56px); align-items: center; box-shadow: 0 30px 60px -40px rgba(20,20,40,.35); }
.p-500 .plug { width: 100%; height: auto; }
.p-500 .plug .spark { animation: spark 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spark { 0%, 100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }
.p-500 h1 { font-size: clamp(2rem, 4.4vw, 3.2rem); font-weight: 800; }
.p-500 .copy > p { color: var(--muted); font-size: 1.08rem; }
.p-500 .actions { margin: 26px 0 24px; }
.status-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.status-list li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.status-list b { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.status-list b::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.status-list li.down b::before { background: var(--brand); box-shadow: 0 0 0 3px #fde2dc; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.status-list span { color: var(--muted); }
.ref { font: 500 .8rem var(--font-mono); color: var(--muted); margin-top: 16px; }
.ref button { font: inherit; background: none; border: 0; color: var(--brand); cursor: pointer; text-decoration: underline; padding: 0 0 0 6px; }
@media (max-width: 820px) { .p-500 .card { grid-template-columns: 1fr; } .p-500 .plug { max-width: 380px; margin: 0 auto; } }

/* ---------- maintenance ---------- */
.p-maint { --bg: #0f3b35; --surface: rgba(255,255,255,.07); --text: #f3f1e8; --muted: #b9cbc6; --line: rgba(255,255,255,.14); --brand: #ffc745; --accent: #ff8a5b; }
.p-maint .btn-primary { color: #2b2100; }
.p-maint .btn-primary:hover { background: #ffd66e; }
.p-maint .btn-ghost { background: transparent; }
.p-maint .code { background: rgba(255,199,69,.15); }
.p-maint .wrap { width: 100%; max-width: 720px; text-align: center; }
.gears { width: 170px; height: 130px; margin: 0 auto 24px; }
.gears .g1 { animation: spin 7s linear infinite; transform-origin: 62px 70px; }
.gears .g2 { animation: spin 5s linear infinite reverse; transform-origin: 122px 46px; }
@keyframes spin { to { transform: rotate(360deg); } }
.p-maint h1 { font-size: clamp(2.3rem, 6vw, 4.2rem); font-weight: 800; }
.p-maint .wrap > p { color: var(--muted); font-size: 1.12rem; max-width: 540px; margin: 0 auto 30px; }
.progress { max-width: 460px; margin: 0 auto 10px; height: 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 72%; border-radius: inherit; background: repeating-linear-gradient(-45deg, var(--brand) 0 12px, color-mix(in srgb, var(--brand) 80%, #fff) 12px 24px); background-size: 34px 34px; animation: stripes 1s linear infinite; }
@keyframes stripes { to { background-position: 34px 0; } }
.eta { font-size: .95rem; color: var(--muted); margin-bottom: 30px; }
.eta b { color: var(--text); }
.p-maint .actions { justify-content: center; margin-bottom: 26px; }
.updates { display: flex; justify-content: center; gap: 10px; list-style: none; padding: 0; margin: 0; }
.updates a { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); transition: background .2s, color .2s; }
.updates a:hover { background: var(--brand); color: #2b2100; }
.updates svg { width: 18px; height: 18px; }

/* ---------- gallery (index) ---------- */
.p-gallery { --bg: #f4f4f7; }
.p-gallery main { display: block; max-width: 1240px; margin: 0 auto; width: 100%; }
.p-gallery header.intro { text-align: center; max-width: 640px; margin: 20px auto 44px; }
.p-gallery header.intro h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 800; }
.p-gallery header.intro p { color: var(--muted); font-size: 1.1rem; }
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; list-style: none; padding: 0; margin: 0; }
.shot a { display: block; text-decoration: none; background: #fff; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; transition: transform .25s, box-shadow .25s; }
.shot a:hover { transform: translateY(-4px); box-shadow: 0 24px 50px -28px rgba(20,20,50,.45); }
.shot .frame { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--line); }
.shot iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 800px; border: 0; transform: scale(var(--s, .3)); transform-origin: 0 0; pointer-events: none; }
.shot .meta { padding: 16px 18px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.shot b { display: block; font-size: 1.08rem; }
.shot span { color: var(--muted); font-size: .9rem; }
.shot .go { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); transition: background .2s, color .2s; }
.shot a:hover .go { background: var(--brand); color: #fff; }
@media (max-width: 980px) { .shots { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .shots { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .glitch::before, .glitch::after { display: none; }
}
