/* s1.rezafara.com shared design system.
   A page chooses its theme with <html data-course="portal|micro2|micro1|networks|prog2|prog1|arcade">. */

:root {
  --bg: #0a0a1a;
  --panel: rgba(16, 16, 36, 0.82);
  --panel-edge: rgba(255, 255, 255, 0.09);
  --tile: rgba(255, 255, 255, 0.035);
  --ink: #f2f3f8;
  --ink-soft: rgba(242, 243, 248, 0.66);
  --ink-faint: rgba(242, 243, 248, 0.4);
  --accent: #a5b4fc;
  --accent-2: #c084fc;
  --accent-rgb: 165, 180, 252;
  --warn: #fbbf24;
  --danger: #fb7185;
  --ok: #4ade80;
  --display: "Chakra Petch", "Avenir Next Condensed", "Segoe UI", sans-serif;
  --body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --radius: 14px;
  --radius-sm: 8px;
  --wrap: 1040px;
  --bar-h: 52px;
}
html[data-course="micro2"]   { --bg: #0d0a1a; --panel: rgba(19, 14, 36, 0.86); --accent: #c4b5fd; --accent-2: #f0abfc; --accent-rgb: 196, 181, 253; }
html[data-course="micro1"]   { --bg: #130d07; --panel: rgba(28, 19, 10, 0.88); --accent: #fbbf24; --accent-2: #fb923c; --accent-rgb: 251, 191, 36; }
html[data-course="networks"] { --bg: #020d14; --panel: rgba(4, 22, 32, 0.88); --accent: #67e8f9; --accent-2: #22d3ee; --accent-rgb: 103, 232, 249; }
html[data-course="prog2"]    { --bg: #0b0f0d; --panel: rgba(13, 22, 18, 0.88); --accent: #34d399; --accent-2: #a7f3d0; --accent-rgb: 52, 211, 153; }
html[data-course="prog1"]    { --bg: #07111f; --panel: rgba(10, 24, 42, 0.88); --accent: #7dd3fc; --accent-2: #38bdf8; --accent-rgb: 125, 211, 252; }
html[data-course="arcade"]   { --bg: #050508; --panel: rgba(12, 12, 20, 0.9); --accent: #39ff88; --accent-2: #ff4fd8; --accent-rgb: 57, 255, 136; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); }
code, kbd { font-family: var(--mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

#bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* ---------- Top bar (built by site.js) ---------- */
.s1-bar {
  position: sticky; top: 0; z-index: 50;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-edge);
  font-size: 0.9rem;
}
.s1-crumbs { display: flex; align-items: center; gap: 0.5rem; min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; }
.s1-crumbs a, .s1-crumbs span { color: var(--ink-soft); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.s1-crumbs a:hover { color: var(--ink); }
.s1-crumbs .s1-home { font-family: var(--display); font-weight: 700; color: var(--ink); letter-spacing: 0.02em; flex: none; }
.s1-crumbs .s1-home i { color: var(--accent); font-style: normal; }
.s1-crumbs .s1-sep { color: var(--ink-faint); flex: none; }
.s1-crumbs .s1-here { color: var(--accent); }
.s1-actions { display: flex; align-items: center; gap: 0.5rem; flex: none; }
.s1-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  height: 32px; padding: 0 0.8rem;
  border-radius: 999px; border: 1px solid var(--panel-edge);
  background: transparent; color: var(--ink-soft);
  font: 500 0.82rem var(--body); text-decoration: none; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.s1-btn:hover { color: var(--ink); border-color: rgba(var(--accent-rgb), 0.5); background: rgba(var(--accent-rgb), 0.08); }
.s1-btn[aria-pressed="false"] .s1-led { background: var(--ink-faint); box-shadow: none; }
.s1-led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
@media (max-width: 560px) { .s1-btn .s1-label-long { display: none; } }

/* ---------- Page frame ---------- */
.page-wrapper, body > .container {
  position: relative; z-index: 1;
  max-width: var(--wrap); margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1rem, 4vw, 2rem) 5rem;
}
/* old back links are replaced by the top bar */
.nav-back, .nav-breadcrumb, .header > .back-btn { display: none; }

/* ---------- Hero ---------- */
.header { position: relative; margin-bottom: clamp(2rem, 5vw, 3.5rem); padding-left: clamp(0rem, 2vw, 1.25rem); }
.header::before {
  content: ""; position: absolute; left: 0; top: 0.4rem; bottom: 0.4rem; width: 3px; border-radius: 3px;
  background: linear-gradient(var(--accent), var(--accent-2) 60%, transparent);
}
@media (max-width: 700px) { .header { padding-left: 1rem; } }
.header-chip, .header-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font: 500 0.82rem var(--mono); color: var(--accent);
  margin-bottom: 1rem;
}
.header-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: s1-blink 2.4s ease-in-out infinite; }
@keyframes s1-blink { 50% { opacity: 0.35; } }
.header .course-icon { display: none; }
.header h1 {
  font-size: clamp(2.4rem, 7.5vw, 4.6rem);
  font-weight: 700; letter-spacing: -0.015em;
  color: var(--ink);
}
.header .subtitle, .header > p {
  margin-top: 0.9rem; max-width: 46ch;
  font-size: clamp(1rem, 2.2vw, 1.2rem); color: var(--ink-soft);
}
.s1-caret { display: inline-block; width: 0.55em; height: 0.9em; margin-left: 0.08em; vertical-align: -0.06em; background: var(--accent); animation: s1-blink 1s steps(1) infinite; }

/* ---------- Sections ---------- */
.section {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  margin-bottom: 1.25rem;
}
.section-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.section h2 {
  font-size: 1.3rem; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 0.6rem;
}
.section > h2 { margin-bottom: 1.1rem; }
.section-line { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.45), transparent); }
.info-card { border-left: 3px solid var(--accent); padding-left: 1rem; }
.empty-state { color: var(--ink-faint); font-size: 0.95rem; padding: 0.5rem 0; }
.s1-notice {
  border: 1px solid rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08);
  color: #fde68a; border-radius: var(--radius-sm); padding: 0.9rem 1.1rem;
}

/* ---------- Resource tiles ---------- */
.file-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
@media (max-width: 720px) { .file-grid { grid-template-columns: 1fr; } }
.file-item {
  position: relative; display: block;
  padding: 1rem 1.1rem 1rem 1.25rem;
  background: var(--tile);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: inherit; text-decoration: none;
  transition: border-color .18s, background .18s, transform .18s;
}
.file-item::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0;
  background: rgba(var(--accent-rgb), 0.35); transition: background .18s, top .18s, bottom .18s;
}
.file-item.lab-item::before { background: color-mix(in srgb, var(--accent-2) 55%, transparent); }
.file-item:hover { border-color: rgba(var(--accent-rgb), 0.55); background: rgba(var(--accent-rgb), 0.07); transform: translateX(3px); }
.file-item:hover::before { background: var(--accent); top: 0; bottom: 0; }
.file-title { font-weight: 600; font-size: 1rem; color: var(--ink); line-height: 1.35; }
.file-type { margin-top: 0.3rem; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.5; }
.file-type > span:first-child { margin-right: 0.3rem; }
.sub-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.5rem; }
.sub-links a { font-size: 0.86rem; color: var(--accent); text-decoration: none; border-bottom: 1px dashed rgba(var(--accent-rgb), 0.4); }
.sub-links a:hover { border-bottom-style: solid; }

/* Game tiles inside a course page */
.play-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.75rem; }
.play-tile {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.9rem 1rem; border-radius: var(--radius-sm);
  border: 1px dashed rgba(var(--accent-rgb), 0.45);
  color: inherit; text-decoration: none;
  transition: background .18s, border-color .18s;
}
.play-tile:hover { background: rgba(var(--accent-rgb), 0.1); border-style: solid; border-color: var(--accent); }
.play-tile b { font-family: var(--display); font-size: 1.05rem; color: var(--accent); }
.play-tile span { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.45; }

/* ---------- Portal ---------- */
.course-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; }
.course-card {
  --c: var(--accent); --c-rgb: var(--accent-rgb);
  grid-column: span 3;
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; min-height: 190px;
  padding: 1.4rem 1.5rem;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: border-color .2s, transform .2s;
}
.course-card.is-small { grid-column: span 2; min-height: 150px; }
.course-card[data-theme="micro2"]   { --c: #c4b5fd; --c-rgb: 196, 181, 253; }
.course-card[data-theme="micro1"]   { --c: #fbbf24; --c-rgb: 251, 191, 36; }
.course-card[data-theme="networks"] { --c: #67e8f9; --c-rgb: 103, 232, 249; }
.course-card[data-theme="prog2"]    { --c: #34d399; --c-rgb: 52, 211, 153; }
.course-card[data-theme="prog1"]    { --c: #7dd3fc; --c-rgb: 125, 211, 252; }
.course-card[data-theme="arcade"]   { --c: #39ff88; --c-rgb: 57, 255, 136; }
.course-card:hover { border-color: rgba(var(--c-rgb), 0.7); transform: translateY(-3px); }
.course-card .course-code { font: 500 0.8rem var(--mono); color: var(--c); }
.course-card .course-title { font: 600 1.55rem/1.15 var(--display); margin-top: 0.35rem; color: var(--ink); }
.course-card.is-small .course-title { font-size: 1.2rem; }
.course-card .course-description { margin-top: 0.6rem; font-size: 0.92rem; color: var(--ink-soft); max-width: 38ch; }
.course-card .card-go { margin-top: auto; padding-top: 1rem; font: 500 0.86rem var(--body); color: var(--c); }
.course-card .motif { position: absolute; inset: 0; z-index: -1; opacity: 0.16; transition: opacity .3s; color: var(--c); }
.course-card:hover .motif, .course-card:focus-visible .motif { opacity: 0.6; }
.course-card .motif svg { position: absolute; right: -4%; bottom: -6%; width: 62%; height: auto; }
.course-card .motif .run { animation-play-state: paused; }
.course-card:hover .motif .run, .course-card:focus-visible .motif .run { animation-play-state: running; }
.motif .dash { stroke-dasharray: 10 14; animation: s1-dash 1.4s linear infinite; }
.motif .sweep { stroke-dasharray: 600; stroke-dashoffset: 600; animation: s1-sweep 2.2s linear infinite; }
.motif .pop { animation: s1-pop 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.motif .pop.d2 { animation-delay: .3s; } .motif .pop.d3 { animation-delay: .6s; }
@keyframes s1-dash { to { stroke-dashoffset: -48; } }
@keyframes s1-sweep { to { stroke-dashoffset: 0; } }
@keyframes s1-pop { 50% { transform: scale(1.5); opacity: 0.4; } }
@media (max-width: 760px) {
  .course-card, .course-card.is-small { grid-column: span 6; min-height: 0; }
}
.footer { margin-top: 3rem; color: var(--ink-faint); font-size: 0.86rem; }
.footer-line { display: none; }

/* ---------- Per-course signature details ---------- */
/* Micro 2: section headings read as IC pin labels */
html[data-course="micro2"] .section { counter-increment: pin; }
html[data-course="micro2"] body { counter-reset: pin; }
html[data-course="micro2"] .section h2::before {
  content: counter(pin, decimal-leading-zero);
  font: 500 0.72rem var(--mono); color: var(--bg);
  background: var(--accent); padding: 0.2rem 0.45rem 0.2rem 0.6rem;
  clip-path: polygon(0 50%, 18% 0, 100% 0, 100% 100%, 18% 100%);
}
/* Micro 1: oscilloscope graticule behind the hero */
html[data-course="micro1"] .header {
  padding: 1.75rem 1.5rem; border: 1px solid rgba(var(--accent-rgb), 0.25); border-radius: var(--radius);
  background:
    linear-gradient(rgba(var(--accent-rgb), 0.09) 1px, transparent 1px) 0 0 / 100% 2.5rem,
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.09) 1px, transparent 1px) 0 0 / 2.5rem 100%,
    rgba(19, 13, 7, 0.7);
}
html[data-course="micro1"] .header::before { display: none; }
/* Networks: tiles are nodes on a link */
html[data-course="networks"] .file-item::after {
  content: ""; position: absolute; right: 0.9rem; top: 1.05rem; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.5); background: var(--bg); transition: background .18s, box-shadow .18s;
}
html[data-course="networks"] .file-item:hover::after { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
html[data-course="networks"] .file-grid { position: relative; }
html[data-course="networks"] .file-title { padding-right: 1.5rem; }
/* Programming 2: terminal prompt */
html[data-course="prog2"] .header h1 { font-family: var(--mono); font-weight: 500; font-size: clamp(1.7rem, 5.6vw, 3.4rem); letter-spacing: -0.03em; }
html[data-course="prog2"] .header h1::before { content: "$ "; color: var(--accent); }
html[data-course="prog2"] .section h2::before { content: ">>>"; font: 500 0.9rem var(--mono); color: var(--accent); }
/* Programming 1: flowchart decision markers */
html[data-course="prog1"] .section h2::before {
  content: ""; width: 0.7rem; height: 0.7rem; flex: none; transform: rotate(45deg);
  border: 2px solid var(--accent); margin: 0 0.25rem;
}

/* ---------- Schedule pages ---------- */
html[data-page="schedule"] { --wrap: 1180px; }
.content { position: relative; }
.course-info {
  display: flex; flex-wrap: wrap; gap: 0.4rem 2rem;
  padding: 1rem 1.25rem; margin-bottom: 1.25rem;
  background: var(--panel); border: 1px solid var(--panel-edge); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); font-size: 0.95rem; color: var(--ink-soft);
}
.course-info strong { color: var(--ink); font-weight: 600; }
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
html[data-page="schedule"] .content h2, html[data-page="schedule"] .content h3 { margin: 2.25rem 0 1rem; font-size: 1.4rem; }
html[data-page="schedule"] table {
  width: 100%; min-width: 640px; border-collapse: collapse;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius);
  font-size: 0.93rem;
}
html[data-page="schedule"] th {
  text-align: left; font: 600 0.85rem var(--display); letter-spacing: 0.03em;
  color: var(--accent); padding: 0.9rem 1rem; border-bottom: 1px solid rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
}
html[data-page="schedule"] td { padding: 0.85rem 1rem; vertical-align: top; border-bottom: 1px solid rgba(255, 255, 255, 0.06); color: var(--ink); }
html[data-page="schedule"] tr:last-child td { border-bottom: 0; }
html[data-page="schedule"] td:nth-child(2) { font-family: var(--mono); font-size: 0.84rem; color: var(--ink-soft); white-space: nowrap; }
.week-number { font: 600 0.9rem var(--display); color: var(--accent); white-space: nowrap; }
.topic-detail { margin-top: 0.3rem; font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5; }
.lab-container, .assignment-container, .test-container, .due-container {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 6px; font-weight: 600; font-size: 0.88rem;
  border: 1px solid; margin: 0.1rem 0;
}
.lab-container { color: #7dd3fc; border-color: rgba(125, 211, 252, 0.4); background: rgba(125, 211, 252, 0.08); }
.assignment-container { color: #fdba74; border-color: rgba(253, 186, 116, 0.4); background: rgba(253, 186, 116, 0.08); }
.test-container { color: #fda4af; border-color: rgba(253, 164, 175, 0.45); background: rgba(253, 164, 175, 0.08); }
.due-container { color: #fde68a; border-color: rgba(253, 230, 138, 0.4); background: rgba(253, 230, 138, 0.07); }
tr.lab-row td:first-child { box-shadow: inset 3px 0 0 #7dd3fc; }
tr.assignment-row td:first-child { box-shadow: inset 3px 0 0 #fdba74; }
tr.exam-row td { background: rgba(251, 113, 133, 0.07); }
tr.exam-row td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.mid-break-row td { background: repeating-linear-gradient(135deg, rgba(255,255,255,0.03) 0 10px, transparent 10px 20px); color: var(--ink-soft); }
tr.preparation-row td { background: rgba(251, 191, 36, 0.05); }
tr.s1-now td { background: rgba(var(--accent-rgb), 0.12); }
tr.s1-now td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.s1-now .week-number::after { content: " · this week"; font: 500 0.75rem var(--body); color: var(--ink); }
.status-badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.76rem; font-weight: 600; border: 1px solid; margin-left: 0.3rem; white-space: nowrap; }
.badge-exam { color: #fda4af; border-color: rgba(253, 164, 175, 0.5); }
.badge-break { color: var(--ink-soft); border-color: var(--panel-edge); }
.badge-assignment { color: #fdba74; border-color: rgba(253, 186, 116, 0.5); }
.badge-warning { color: #fde68a; border-color: rgba(253, 230, 138, 0.5); }

/* ---------- Motion preferences ---------- */
html.s1-still *, html.s1-still *::before, html.s1-still *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  html:not(.s1-moving) *, html:not(.s1-moving) *::before, html:not(.s1-moving) *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Inline colours left over from the old light schedule pages */
html[data-page="schedule"] td a { color: var(--accent) !important; text-decoration: underline !important; text-underline-offset: 3px; }
html[data-page="schedule"] td [style*="#e74c3c"] { color: var(--danger) !important; }

/* Code must show the characters students type: no programming ligatures. */
/* !important because the `font` shorthand resets these on any element that uses it. */
*, *::before, *::after { font-variant-ligatures: none !important; font-feature-settings: "liga" 0, "calt" 0 !important; }

/* ---------- Load sequence and card tilt ---------- */
.s1-rise { animation: s1-rise .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms + 150ms); }
@keyframes s1-rise { from { opacity: 0; transform: translateY(26px) scale(0.985); } }
.course-card, .cab { transform-style: preserve-3d; }
.course-grid, .cab-grid { perspective: 1100px; }
.course-card:hover { transform: translateY(-3px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: border-color .2s, transform .08s linear; }
.course-card::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--c-rgb), 0.2), transparent 60%);
}
.course-card:hover::after { opacity: 1; }
.course-card:hover { box-shadow: 0 18px 50px -18px rgba(var(--c-rgb), 0.55); }

/* The portal hero leaves room for the particle figure beside the title. */
@media (min-width: 901px) {
  html[data-course="portal"] .header { min-height: 250px; display: flex; flex-direction: column; justify-content: center; max-width: 58%; }
}

/* Keep hero text readable over the moving backgrounds. */
.header h1, .header .subtitle, .header > p, .header-chip, .header-badge { text-shadow: 0 0 6px var(--bg), 0 0 18px var(--bg), 0 0 34px var(--bg); }
html[data-course="prog2"] .header::after {
  content: ""; position: absolute; inset: -1.2rem -1.5rem; z-index: -1; border-radius: var(--radius);
  background: radial-gradient(ellipse at 30% 50%, rgba(11, 15, 13, 0.92), rgba(11, 15, 13, 0.55) 65%, transparent);
}
