@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;650;700;750&display=swap');

:root{--mono:Consolas,Menlo,'DejaVu Sans Mono','Liberation Mono',monospace;color-scheme:light;--bg:#f4f7fa;--ink:#172d42;--muted:#50667a;--line:#d6e0e8;--accent:#006e62;--pale:#e3f4ee;--code:#102639}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.6 'Geist',system-ui,sans-serif}header{display:flex;align-items:center;flex-wrap:wrap;gap:24px;padding:18px 30px;background:#fff;border-bottom:1px solid var(--line)}.brand{font-size:20px;white-space:nowrap}nav{display:flex;gap:6px}button,select,textarea{font:inherit}button{padding:8px 16px;border:1px solid var(--line);border-radius:7px;background:#fff;color:var(--ink);cursor:pointer;font-weight:600}button:hover{background:#edf3f7}button:disabled{opacity:.55;cursor:default}button:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid #1585c0;outline-offset:3px}nav button[aria-pressed=true],.primary{background:var(--ink);color:#fff;border-color:var(--ink)}#runtime{margin-left:auto;font-size:14px;color:var(--muted)}#practice{display:grid;grid-template-columns:270px minmax(0,1fr);max-width:1480px;margin:auto}aside{padding:28px 22px;border-right:1px solid var(--line)}.eyebrow{font-size:12px;letter-spacing:.09em;font-weight:700;color:var(--accent)}h1{font-size:25px;line-height:1.2;margin:12px 0 24px}h2{font-size:27px;line-height:1.3;margin:12px 0}h3{font-size:16px;margin:0 0 6px}.workspace{padding:30px 36px;min-width:0}.problem-heading,.editor-top{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap}#progress,#saved,#shortcut{font-size:13px;color:var(--muted)}#prompt{max-width:900px;margin:10px 0}.constraint{font-size:14px;color:var(--muted);margin:0 0 22px}label{display:block;font-size:14px;font-weight:650}select{width:100%;padding:10px;background:#fff;border:1px solid var(--line);border-radius:6px;margin:8px 0 20px}#exercise-list{display:flex;flex-direction:column;gap:5px}#exercise-list button{text-align:left;font-size:14px;border-color:transparent;background:transparent;padding:9px 10px;font-weight:450}#exercise-list button[aria-current=true]{background:var(--ink);color:#fff}textarea{display:block;width:100%;resize:vertical;padding:16px;font:15px/1.6 var(--mono);tab-size:4;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);margin:8px 0;min-width:0}#code{background:var(--code);color:#d8eee9;border-color:var(--code);min-height:250px}.actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:12px 0 22px}.primary:hover{background:#254b64}.feedback{padding:18px 20px;border-left:4px solid var(--accent);background:var(--pale);border-radius:0 8px 8px 0;margin-bottom:24px}.feedback p{margin:0}.feedback.error{border-color:#bd5725;background:#fff0e8}.result-row{padding:10px 0;border-top:1px solid #c5d9d3;margin-top:10px;overflow-wrap:anywhere}.result-row pre{white-space:pre-wrap;font-size:14px;margin:6px 0}.try-grid{display:grid;grid-template-columns:1fr 1fr;gap:24px}.try-grid>section{min-width:0}.field-help{font-size:14px;color:var(--muted);margin:4px 0 10px}pre{white-space:pre-wrap;overflow-wrap:anywhere}#scratch-output{font:14px/1.6 var(--mono);min-height:55px;background:#e7edf2;padding:14px;border-radius:6px}#notes{max-width:1000px;margin:auto;padding:32px}#notes pre{background:#e7edf2;padding:18px;border-radius:8px}#notes table{display:block;max-width:100%;overflow-x:auto;border-collapse:collapse}#notes td,#notes th{padding:8px;border-bottom:1px solid var(--line);text-align:left}#notes a{color:var(--accent)}#notes h2{margin-top:40px}#notes code{font-family:var(--mono)}body [hidden]{display:none!important}@media(max-width:1000px){#practice{grid-template-columns:220px minmax(0,1fr)}.workspace{padding:24px}.try-grid{grid-template-columns:1fr}header{padding:16px 22px}}@media(max-width:720px){#practice{display:block}aside{padding:20px 20px 0;border:0}aside h1,#exercise-list{display:none}aside .eyebrow{margin:0 0 10px}aside select{margin-bottom:0}.workspace{padding:22px 20px}header{gap:12px}#runtime{width:100%;margin:0}h2{font-size:24px}#notes{padding:20px}textarea{font-size:16px}}
.lesson-nav{display:flex;gap:10px;flex-wrap:wrap;padding:12px 30px;background:#e7edf2;border-bottom:1px solid var(--line)}.lesson-nav a{font-size:14px;text-decoration:none;color:var(--ink);padding:7px 12px;border-radius:6px}.lesson-nav a[aria-current=page]{background:#fff;font-weight:700;box-shadow:0 1px 3px #172d4215}.lesson-nav a:focus-visible{outline:3px solid #1585c0;outline-offset:2px}#notes-content{max-width:82ch}#notes-content>p,#notes-content>ul,#notes-content>ol{line-height:1.8}#notes-content h1{font-size:32px;line-height:1.25}#notes-content h3{margin-top:26px;font-size:20px}#notes-content li{margin:8px 0}#notes-content pre{font-size:14px;line-height:1.7}@media(max-width:720px){.lesson-nav{padding:10px 16px;gap:4px}}

/* Give the practice area a clear visual boundary at desktop widths. */
.workspace {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 24px;
}
.lesson-nav a:hover {
  background: #f4f7fa;
}
#exercise-list button:hover:not([aria-current=true]) {
  background: #e7edf2;
}
#exercise-list button[aria-current=true]:hover,
nav button[aria-pressed=true]:hover {
  background: #254b64;
}
a:focus-visible, summary:focus-visible {
  outline: 3px solid #006e62;
  outline-offset: 3px;
}
#progress {
  background: var(--pale);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 650;
}
@media (max-width: 720px) {
  .workspace {
    margin: 16px 12px;
    padding: 18px 16px;
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -.035em;
}
.brand-mark {
  display: grid;
  width: 38px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #007568, #183754);
  color: #fff;
  font: 700 25px/1 system-ui, sans-serif;
  box-shadow: 0 3px 8px #18375430;
}

.code-frame {
  position: relative;
  margin: 8px 0;
  border-radius: 8px;
  background: #101d30;
}
.code-frame .code-backdrop,
.code-frame textarea {
  margin: 0;
  padding: 16px;
  border: 1px solid transparent;
  font: 15px/1.6 var(--mono);
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
}
.code-frame .code-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: #e2e8f5;
}
.code-frame textarea,
.code-frame #code {
  position: relative;
  overflow: auto;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  border-color: #52647c;
}
.code-frame textarea::selection {
  background: #5676ab80;
  color: transparent;
}
.token-keyword { color: #deb0ff; }
.token-builtin { color: #8edbff; }
.token-string { color: #a7ebb5; }
.token-comment { color: #9eafc7; }
.token-number { color: #ffcd9e; }
.token-operator, .token-prompt { color: #82e8d4; }

@media (max-width: 720px) {
  .code-frame .code-backdrop, .code-frame textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .lesson-nav a {
    transition: transform 220ms cubic-bezier(.22,1.5,.4,1), background-color 180ms ease, box-shadow 180ms ease;
  }
  @media (hover: hover) {
    button:not(:disabled):hover, .lesson-nav a:hover {
      transform: translateY(-2px) scale(1.025);
      box-shadow: 0 4px 9px #172d421c;
    }
  }
  button:not(:disabled):active, .lesson-nav a:active {
    transform: translateY(1px) scale(.95);
    transition-duration: 85ms;
  }
}
@media (forced-colors: active) {
  .code-frame .code-backdrop { visibility: hidden; }
  .code-frame textarea, .code-frame #code { color: CanvasText; caret-color: CanvasText; }
  .code-frame textarea::selection { color: HighlightText; background: Highlight; }
}

/* Keep the editable layer transparent so the highlighted text shows through. */
.code-frame .syntax-editor,
.code-frame #code.syntax-editor {
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #f2f6ff;
}
.code-frame .code-backdrop { color: #edf3ff; }
.feedback, .feedback.error { border-radius: 12px; }
#exercise-select {
  appearance: none;
  padding: 10px 36px 10px 12px;
  color: var(--ink);
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%2350667a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
#exercise-select:hover { border-color: var(--muted); }
.challenge { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.challenge h2 { font-size: 14px; margin: 0 0 8px; }
.challenge button[aria-pressed=true] { background: var(--ink); color: #fff; }
@media (forced-colors: active) {
  #exercise-select { appearance: auto; background: Canvas; }
  .code-frame .syntax-editor, .code-frame #code.syntax-editor {
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
}

/* Keep pointer feedback in the spring animation and preserve keyboard focus. */
button, select, summary, .lesson-nav a {
  -webkit-tap-highlight-color: transparent;
}

.practice-hint > summary {
  cursor: pointer;
}

@supports selector(details::details-content) {
  @media (prefers-reduced-motion: no-preference) {
    .practice-hint {
      interpolate-size: allow-keywords;
    }

    .practice-hint::details-content {
      block-size: 0;
      opacity: 0;
      overflow: clip;
      transition:
        block-size 250ms cubic-bezier(.22, .75, .25, 1),
        opacity 180ms ease,
        content-visibility 250ms allow-discrete;
    }

    .practice-hint[open]::details-content {
      block-size: auto;
      opacity: 1;
    }
  }
}

/* Paint guides in leading whitespace without changing editor text metrics. */
.token-indent {
  background: repeating-linear-gradient(
    to right, #6e88ad55 0 1px, transparent 1px 4ch
  );
}
.code-frame .code-backdrop, .code-frame textarea {
  font-variant-ligatures: none;
}

.brand {
  color: var(--ink);
  text-decoration: none;
}
header, .lesson-nav {
  margin: 12px clamp(10px, 2vw, 28px);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.lesson-nav a { border-radius: 999px; }
.home {
  min-height: 100vh;
  background: radial-gradient(ellipse at top right, #1c3c62, #0d1c32 60%);
  color: #f2f6ff;
}
.home main, .home footer {
  max-width: 1120px;
  margin: auto;
  padding: 32px clamp(20px, 5vw, 56px);
}
.home .brand { color: inherit; }
.home h1 {
  font-size: clamp(42px, 8vw, 84px);
  letter-spacing: -.06em;
  margin: 24px 0 12px;
}
.home p { color: #c3d3e8; max-width: 59ch; }
.home h2 { margin-top: 42px; }
.lesson-cards {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr));
  gap: 12px;
}
.lesson-cards a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  min-height: 66px;
  background: #1b304c;
  border: 1px solid #385170;
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
  font-weight: 650;
}
.lesson-cards a:hover { background: #29466a; }
.lesson-cards span {
  padding: 3px 8px;
  border-radius: 8px;
  background: #294966;
  color: #a8f3e4;
  font-variant-numeric: tabular-nums;
}
.home a:focus-visible { outline-color: #a8f3e4; }
.home footer { color: #c3d3e8; padding-top: 0; }
.home footer a { color: #a8f3e4; margin-right: 16px; }

.home a { -webkit-tap-highlight-color: transparent; }
.home footer a {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  margin-right: 8px;
  border: 1px solid #385170;
  border-radius: 999px;
  background: #1b304c;
  text-decoration: none;
  font-weight: 650;
}
.home footer a:hover { background: #29466a; }
.lesson-cards a:active, .home footer a:active {
  background: #365b86;
  border-color: #749bc6;
}
@media (prefers-reduced-motion: no-preference) {
  .home a {
    transition: transform 240ms cubic-bezier(.22, 1.65, .4, 1),
      background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  }
  @media (hover: hover) {
    .home a:hover {
      transform: translateY(-3px) scale(1.025);
      box-shadow: 0 5px 0 #253f60;
    }
  }
  .home a:active {
    transform: translateY(1px) scale(.97);
    box-shadow: none;
    transition-duration: 80ms;
  }
}

/* The lesson logo is a link outside the homepage. */
header a.brand {
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
header a.brand:active { background-color: #e1effa; }
header a.brand:active .brand-mark {
  background: #28738a;
  box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
  header a.brand {
    transition: transform 240ms cubic-bezier(.22, 1.65, .4, 1),
      background-color 150ms ease;
  }
  @media (hover: hover) {
    header a.brand:hover { transform: translateY(-3px) scale(1.035); }
  }
  header a.brand:active {
    transform: translateY(1px) scale(.96);
    transition-duration: 80ms;
  }
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 310px);
  align-items: center;
  gap: 28px;
}
.home .profile-card {
  padding: 25px;
  border: 1px solid #587ba0;
  border-radius: 20px;
  background: linear-gradient(145deg, #264366, #192f4b);
  box-shadow: 0 12px 24px #06112680;
}
.home .profile-card h2 {
  margin: 0 0 14px;
  font-size: 19px;
}
.home .profile-links {
  padding: 0;
  display: grid;
  gap: 10px;
}
.home .profile-card a {
  gap: 10px;
  padding: 10px 14px;
  margin: 0;
  border-color: #7094b7;
}
@media (max-width: 720px) {
  .home-intro { grid-template-columns: 1fr; gap: 16px; }
  .home .profile-card { width: min(100%, 340px); }
}
.home .python-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: .23em;
  row-gap: .06em;
}
.python-word { color: #a8f3e4; white-space: nowrap; }
.python-logo {
  width: .69em;
  height: auto;
  object-fit: contain;
}

/* Keep the wide monospace heading comfortably inside the intro column. */
.home h1 { font-size: clamp(34px, 6vw, 72px); }
.home .python-title { letter-spacing: -.045em; }

.profile-icon { flex: none; display: block; }
.profile-icon--github { filter: brightness(0) invert(1); }

@keyframes lesson-link-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  32% { transform: translateY(-8px) scale(1.065); }
  60% { transform: translateY(2px) scale(.985); }
  80% { transform: translateY(-3px) scale(1.02); }
}

@media (prefers-reduced-motion: no-preference) {
  .lesson-nav a {
    transition: transform 100ms ease, background-color 180ms ease, box-shadow 180ms ease;
  }

  .lesson-nav a:is(:hover, :focus-visible):not(:active) {
    animation: lesson-link-bounce 480ms ease-in-out;
  }

  .lesson-nav a:active {
    transform: translateY(2px) scale(.94);
  }
}

/* Compact desktop lessons while preserving browser zoom and mobile sizing. */
@media (min-width: 1100px) {
  body:not(.home) { zoom: .9; }
}

@view-transition {
  navigation: none;
}
