/* =========================================================================
   Pythonation — "we are rebuilding" page
   Brand: October 2026. Paper #E6E6E7 · crimson #B32351 · blue #4F72A2 ·
   wire #496A95 · ink #1F2A3D · night #141A2A · light blue #8FB0DA.
   Type: IBM Plex Sans Arabic (Arabic + Latin), IBM Plex Mono (labels),
   IBM Plex Sans SC (Chinese). Self-hosted, subset. Logical properties only.
   ========================================================================= */

/* ---------------- Fonts ---------------- */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-arabic-ar-400.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+200C-200F, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url("../fonts/plex-arabic-ar-600.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+200C-200F, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-arabic-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2013-2014, U+2018-201D, U+2022, U+2026, U+20AC, U+2122; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url("../fonts/plex-arabic-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2013-2014, U+2018-201D, U+2022, U+2026, U+20AC, U+2122; }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap;
  src: url("../fonts/plex-mono-500.woff2") format("woff2"); }
@font-face { font-family: "Plex SC"; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-sc-400.woff2") format("woff2"); }
@font-face { font-family: "Plex SC"; font-weight: 600; font-display: swap;
  src: url("../fonts/plex-sc-600.woff2") format("woff2"); }

/* ---------------- Tokens ---------------- */
:root {
  --paper: #E6E6E7;
  --crimson: #B32351;
  --blue: #4F72A2;
  --wire: #496A95;
  --ink: #1F2A3D;
  --night: #141A2A;
  --lightblue: #8FB0DA;

  --bg: var(--paper);
  --text: var(--ink);
  --muted: #4A5568;
  --accent: var(--crimson);
  --accent-ink: #fff;
  --link: var(--blue);
  --card: #EFEFF0;
  --card-line: rgba(31, 42, 61, 0.10);
  --shadow: 0 1px 2px rgba(20, 26, 42, 0.05), 0 12px 40px -12px rgba(20, 26, 42, 0.16);
  --field: #fff;
  --dot: 79, 114, 162; /* blue, as rgb for the canvas */
  --word: var(--blue);
  --wire-stroke: var(--wire);

  --font: "Plex Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 28px;
  --radius-lg: 40px;
  --maxw: 1080px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
:lang(zh-Hans) { --font: "Plex SC", "Plex Arabic", "PingFang SC", "Microsoft YaHei", sans-serif; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--night);
    --text: var(--paper);
    --muted: #A9B4C6;
    --link: var(--lightblue);
    --card: #1A2134;
    --card-line: rgba(143, 176, 218, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 48px -16px rgba(0, 0, 0, 0.6);
    --field: #0F1422;
    --dot: 143, 176, 218;
    --word: var(--lightblue);
    --wire-stroke: var(--lightblue);
  }
}

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:lang(zh-Hans) body, body:lang(zh-Hans) { line-break: strict; word-break: normal; }
a { color: var(--link); text-underline-offset: 3px; }
img, svg { display: block; max-width: 100%; }
.mono { font-family: var(--mono); font-weight: 500; letter-spacing: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--crimson); color: #fff; }

.wrap { width: min(100% - 32px, var(--maxw)); margin-inline: auto; }
.sr, .hp { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 16px; top: -60px; z-index: 10; padding: 8px 14px;
  background: var(--ink); color: #fff; border-radius: 10px; }
.skip:focus { top: 12px; }

/* The moving dot grid sits behind everything. */
.dots { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
header, main, footer { position: relative; z-index: 1; }

/* ---------------- Header ---------------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand img { border-radius: 9px; }
.brand .mono { font-size: 15px; }
.langs ul { display: flex; gap: 4px; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--card-line); border-radius: 999px; }
.langs a { display: block; padding: 6px 14px; border-radius: 999px; color: var(--muted);
  text-decoration: none; font-size: 14px; line-height: 1.4; }
.langs a { white-space: nowrap; }
@media (max-width: 420px) {
  .brand .mono { display: none; }
  .langs a { padding: 6px 11px; font-size: 13px; }
}
.langs a:hover { color: var(--text); }
.langs a[aria-current="page"] { background: var(--ink); color: var(--paper); }
@media (prefers-color-scheme: dark) { .langs a[aria-current="page"] { background: var(--paper); color: var(--night); } }
.langs a[lang="ar"] { font-family: "Plex Arabic", sans-serif; }
.langs a[lang="zh-Hans"] { font-family: "Plex SC", sans-serif; }

/* ---------------- Hero ---------------- */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center;
  padding-block: clamp(8px, 3vw, 32px) clamp(48px, 8vw, 88px); }
.logo-wrap { width: clamp(190px, 34vw, 290px); aspect-ratio: 1; margin-block-end: 8px; outline: none; }
.logo { width: 100%; height: 100%; overflow: visible; }

.eyebrow { color: var(--blue); font-size: 13px; margin-block-end: 14px; }
.eyebrow span { color: var(--crimson); }
@media (prefers-color-scheme: dark) { .eyebrow { color: var(--lightblue); } }

/* Bilingual titles: lead language on top, English underneath. */
.bi { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; }
.bi-1 { line-height: 1.35; }
.bi-2 { font-family: var(--mono); font-weight: 400; font-size: 0.42em; color: var(--muted);
  letter-spacing: 0; line-height: 1.5; }
h1.bi { font-size: clamp(30px, 5.6vw, 52px); max-width: 18ch; }
:lang(zh-Hans) h1.bi { max-width: 16em; }
h1.bi .bi-2 { font-size: clamp(14px, 1.8vw, 17px); margin-block-start: 6px; }

.lede { max-width: 54ch; margin-block: 18px 30px; color: var(--muted); font-size: clamp(17px, 2vw, 19px); }

/* ---------------- Form ---------------- */
.notify { width: min(100%, 540px); }
.field { display: flex; gap: 8px; padding: 6px; background: var(--field);
  border: 1px solid var(--card-line); border-radius: 999px; box-shadow: var(--shadow); }
.field:focus-within { border-color: var(--blue); }
.field input { flex: 1; min-width: 0; padding: 10px 18px; border: 0; background: transparent;
  color: var(--text); font: 16px/1.4 var(--mono); outline: none; text-align: start; }
html[dir="rtl"] .field input { text-align: right; }
html[dir="rtl"] .field input:not(:placeholder-shown) { text-align: left; }
.field input::placeholder { color: var(--muted); opacity: .7; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  font: 600 16px/1.3 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #9B1D46; }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--card-line); color: var(--text); }
.btn-ghost:hover { border-color: var(--blue); }
.btn .ic { width: 18px; height: 18px; fill: currentColor; }
.form-msg { min-height: 1.7em; margin-block-start: 12px; font-weight: 600; }
.form-msg.ok { color: #1F7A4D; }
.form-msg.err { color: var(--crimson); }
@media (prefers-color-scheme: dark) { .form-msg.ok { color: #6FD3A0; } .form-msg.err { color: #F07A9C; } }
.fine { font-size: 14px; color: var(--muted); }

.partner { margin-block-start: 28px; color: var(--muted); }
.partner a { font-size: 15px; }

@media (max-width: 520px) {
  .field { flex-direction: column; border-radius: 26px; padding: 8px; }
  .field input { padding: 12px 14px; text-align: center !important; }
  .btn-primary { width: 100%; padding-block: 14px; }
}

/* ---------------- Cards ---------------- */
.grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; padding-block-end: 56px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.card { padding: clamp(22px, 3.4vw, 34px); background: var(--card); border: 1px solid var(--card-line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card .bi { align-items: flex-start; font-size: 24px; margin-block-end: 18px; text-align: start; }
.card .bi .bi-2 { font-size: 13px; }
.card .bi.small { font-size: 20px; margin-block-end: 8px; }
.card hr { border: 0; border-block-start: 1px solid var(--card-line); margin-block: 26px; }
.muted { color: var(--muted); font-size: 15px; }

/* Night window — the episode card, like the brand code window. */
.card-night { background: var(--night); color: var(--paper); border-color: rgba(143, 176, 218, .16); }
.card-night .bi-2 { color: var(--lightblue); }
@media (prefers-color-scheme: dark) { .card-night { background: #0D1220; } }
.win-bar { display: flex; align-items: center; gap: 7px; margin-block-end: 20px; }
.win-bar i { width: 11px; height: 11px; border-radius: 50%; background: #2A3550; }
.win-bar i:first-child { background: var(--crimson); }
.win-bar span { margin-inline-start: auto; font-size: 12px; color: var(--lightblue); opacity: .8; }

.yt { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: #0A0E19; border: 1px solid rgba(143, 176, 218, .14); }
.yt-fallback, .yt-play { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center;
  color: var(--paper); text-decoration: none; }
.yt-fallback .ic { width: 44px; height: 44px; fill: var(--crimson); }
.yt-play { padding: 0; border: 0; background: #000; cursor: pointer; width: 100%; }
.yt-play img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9;
  transition: opacity .3s var(--ease); }
.yt-play:hover img { opacity: 1; }
.yt-play .play { position: relative; width: 68px; height: 68px; border-radius: 50%;
  background: var(--crimson); display: grid; place-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.yt-play .play::before { content: ""; margin-inline-start: 5px; border-block: 12px solid transparent;
  border-inline-start: 20px solid #fff; }
html[dir="rtl"] .yt-play .play::before { margin-inline-start: 0; margin-inline-end: 5px;
  border-inline-start: 0; border-inline-end: 20px solid #fff; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ep-meta { margin-block-start: 16px; display: flex; flex-direction: column; gap: 4px; }
.ep-title { font-weight: 600; line-height: 1.5; }
.ep-link { font-size: 14px; color: var(--lightblue); }
.ep-date { font-size: 13px; color: var(--lightblue); opacity: .75; }

/* Social list */
.social { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 400px) { .social { grid-template-columns: 1fr; } }
.social a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  color: var(--text); text-decoration: none; transition: background-color .2s var(--ease); }
.social a:hover { background: rgba(79, 114, 162, .10); }
.social .ic { flex: none; width: 18px; height: 18px; fill: var(--crimson); }
.social .s-name { font-weight: 600; font-size: 15px; }
.social .s-handle { margin-inline-start: auto; font: 400 12px/1.3 var(--mono); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 560px) { .social .s-handle { display: none; } }
.support { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 16px; }
.support .ic { fill: var(--crimson); }

/* Small standalone pages (confirm link, no-JS form result). */
.standalone { min-height: 100vh; justify-content: center; }
.standalone-mark { border-radius: 18px; margin-block-end: 24px; }
.form-msg.big { font-size: 20px; max-width: 36ch; }

/* ---------------- Footer ---------------- */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding-block: 24px 40px; border-block-start: 1px solid var(--card-line); color: var(--muted); font-size: 14px; }

/* ---------------- Logo: drawn like a pen ----------------
   1. the wireframe draws in, 2. the brain outline is drawn,
   3. the ink fills the brain from the bottom, 4. the wordmark settles in.
   The brain never pops or scales in. */
.logo .wire path { fill: none; stroke: var(--wire-stroke); stroke-opacity: .34; stroke-width: 1.1;
  stroke-linejoin: round; stroke-dasharray: 100; stroke-dashoffset: 100;
  animation: pyn-draw 1.4s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 16ms); }
.logo .sig path { fill: none; stroke: var(--crimson); stroke-width: 2.6; stroke-linecap: round;
  stroke-dasharray: 14 100; stroke-dashoffset: 14; opacity: 0; }
.logo .brain-line { fill: none; stroke: var(--crimson); stroke-width: 3; stroke-linejoin: round;
  stroke-dasharray: 100; stroke-dashoffset: 100; animation: pyn-draw 1.6s cubic-bezier(.45,.05,.35,1) .35s forwards,
  pyn-fade .6s ease 2.6s forwards; }
.logo .brain-ink { fill: var(--crimson); }
.logo .ink-rect { transform: translateY(460px); animation: pyn-ink 1.2s cubic-bezier(.55,.1,.3,1) 1.55s forwards; }
.logo .word path { fill: var(--word); }
.logo .word { opacity: 0; animation: pyn-word .9s var(--ease) 2.3s forwards; }
.logo .brain { transform-box: view-box; transform-origin: 336.4px 543.1px; }

@keyframes pyn-draw { to { stroke-dashoffset: 0; } }
@keyframes pyn-fade { to { stroke-opacity: 0; } }
@keyframes pyn-ink { to { transform: translateY(0); } }
@keyframes pyn-word { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pyn-sig { 0% { stroke-dashoffset: 14; opacity: 0; } 15% { opacity: .9; } 85% { opacity: .9; } 100% { stroke-dashoffset: -100; opacity: 0; } }
@keyframes pyn-beat { 0%, 40%, 100% { transform: scale(1); } 12% { transform: scale(1.045); } 24% { transform: scale(1.015); } 32% { transform: scale(1.03); } }

/* After the intro, hover plays the brand hover animation (signals + heartbeat). */
.logo-wrap.ready:hover .sig path { animation: pyn-sig 1.6s linear infinite; animation-delay: calc(.2s + var(--s, 0) * .2s); }
.logo-wrap.ready:hover .brain { animation: pyn-beat 1.6s ease-in-out .15s infinite; }

@media (prefers-reduced-motion: reduce) {
  .logo *, .logo-wrap * { animation: none !important; transition: none !important; }
  .logo .wire path, .logo .brain-line { stroke-dashoffset: 0; }
  .logo .brain-line { stroke-opacity: 0; }
  .logo .ink-rect { transform: none; }
  .logo .word { opacity: 1; }
  .btn, .social a, .yt-play img { transition: none; }
}
