/* ============ Xcode "Default (Light)" / "Default (Dark)" ============
   Follows the system setting; the toggle sets data-theme on <html>. */
:root {
  color-scheme: light dark;
  --bg:     light-dark(#ffffff, #1f1f24);
  --chrome: light-dark(#f6f6f6, #26262b);
  --line:   light-dark(#e5e5e5, #34343a);
  --text:   light-dark(#1d1d1f, #e6e6e6);
  --dim:    light-dark(#8a8a8e, #6c6c72);
  --hl:     light-dark(#ecf5ff, #23252b);   /* current line */
  --k:      light-dark(#9b2393, #fc5fa3);   /* keywords */
  --s:      light-dark(#c41a16, #fc6a5d);   /* strings */
  --n:      light-dark(#1c00cf, #d0bf69);   /* numbers */
  --c:      light-dark(#5d6c79, #7f8c98);   /* comments */
  --a:      light-dark(#815f03, #fd8f3f);   /* attributes */
  --t:      light-dark(#0b4f79, #5dd8ff);   /* project types */
  --tx:     light-dark(#3900a0, #d0a8ff);   /* system types */
  --d:      light-dark(#0f68a0, #41a1c0);   /* declarations */
  --m:      light-dark(#6c36a9, #a167e6);   /* members / cases */
  --fn:     light-dark(#326d74, #67b7a4);   /* project functions */
  --ok:     light-dark(#28a745, #30d158);
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  --fs: 14px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs)/1.7 var(--mono);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ Tabs + jump bar ============ */
.tabs {
  position: sticky; top: 0; z-index: 5;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 12px;
}
.tabs__top { display: flex; align-items: stretch; }
.tabs__row { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.theme-toggle {
  flex: none; display: flex; align-items: center; gap: 2px;
  margin: 0; padding: 0 16px;
  border: 0; border-left: 1px solid var(--line);
  background: none; color: var(--dim);
  font: 12px/1 var(--mono); cursor: pointer;
  transition: color .15s;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .m { font-weight: 600; }
.tabs__row::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  color: var(--dim);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--bg); color: var(--text); box-shadow: inset 0 -1px 0 var(--bg); }
.swift-icon {
  width: 12px; height: 12px; border-radius: 3px; flex: none;
  background: linear-gradient(160deg, #f88a36, #fd2020);
}
.jumpbar {
  padding: 5px 18px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jumpbar b { color: var(--text); font-weight: 500; }

/* ============ Editor ============ */
.editor { padding: 28px 0 40px; }
.code { counter-reset: ln; max-width: 1040px; }

.l {
  --gw: 64px;              /* gutter width */
  --ind: 0;
  counter-increment: ln;
  position: relative;
  min-height: 1.7em;
  padding-left: calc(var(--gw) + var(--ind) * 4ch + 2ch);
  text-indent: -2ch;       /* hanging indent when a line wraps */
  padding-right: 24px;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0;
  animation: in .35s ease forwards;
  animation-delay: var(--delay, 0ms);
}
.l::before {
  content: counter(ln);
  position: absolute; left: 0; width: calc(var(--gw) - 22px);
  text-align: right; text-indent: 0;
  color: var(--dim); opacity: .7;
  user-select: none;
}
.l:hover { background: var(--hl); }
.l:hover::before { color: var(--text); opacity: 1; }
.i1 { --ind: 1; } .i2 { --ind: 2; } .i3 { --ind: 3; }

@keyframes in { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

/* Tokens */
.k  { color: var(--k); font-weight: 600; }
.s  { color: var(--s); }
.n  { color: var(--n); }
.c  { color: var(--c); }
.doc { font-style: italic; }
.a  { color: var(--a); }
.t  { color: var(--t); }
.tx { color: var(--tx); }
.d  { color: var(--d); font-weight: 600; }
.m  { color: var(--m); }
.fn { color: var(--fn); }

/* ⌘-click style links */
.code a { border-radius: 3px; transition: background .15s; }
.code a:hover { text-decoration: underline; text-underline-offset: 3px; background: color-mix(in srgb, currentColor 10%, transparent); }

/* ============ Debug console ============ */
.console {
  border-top: 1px solid var(--line);
  background: var(--chrome);
  scroll-margin-top: 70px;
}
.console__bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans); font-size: 12px; color: var(--dim);
}
.build { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-weight: 500; }
.build__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

.console__body { padding: 20px 24px 28px; max-width: 1040px; }
.prompt { color: var(--text); }
.lldb { color: var(--dim); }
.out { color: var(--dim); margin-top: 6px; }

.cursor {
  display: inline-block; width: .6em; height: 1.15em; vertical-align: -.2em;
  background: var(--text);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Laurel badges */
.awards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 14px;
}
.award {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 4px;
  border-radius: 10px;
  color: var(--text);
  transition: background .2s, transform .2s;
}
.award:hover, .award.is-hot { background: var(--bg); transform: translateY(-2px); }
.award.is-hot { box-shadow: 0 0 0 1px var(--m); }
.laurel {
  flex: none; width: 34px; height: 72px;
  background: currentColor;                       /* tinted by the theme */
  -webkit-mask: url(assets/laurel.png) center / contain no-repeat;
          mask: url(assets/laurel.png) center / contain no-repeat;
}
.laurel--r { transform: scaleX(-1); }
.award__body {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  font-family: var(--sans); min-width: 0;
}
.award__apple { width: 17px; height: 20px; fill: currentColor; margin-bottom: 3px; }
.award b { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; line-height: 1.15; }
.award small { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); margin-top: 3px; }

/* ============ Apps.swift ============ */
.editor--file { border-top: 1px solid var(--line); scroll-margin-top: 70px; }
#experience { min-height: 70vh; }   /* last file: tall enough to become the active tab */
.lit {                       /* Xcode-style image literal */
  width: 1.35em; height: 1.35em; vertical-align: -.35em;
  border-radius: 22%; box-shadow: 0 0 0 .5px var(--line);
}

/* ============ Stubs + status bar ============ */
.stub {
  padding: 48px 0 48px 88px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 70px;
}
.status {
  position: sticky; bottom: 0;
  display: flex; justify-content: flex-end; gap: 18px;
  padding: 4px 18px;
  background: var(--chrome);
  border-top: 1px solid var(--line);
  font-family: var(--sans); font-size: 11px; color: var(--dim);
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .awards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  :root { --fs: 12px; }
  .l { --gw: 38px; padding-right: 12px; }
  .l::before { width: calc(var(--gw) - 12px); }
  .i1 { --ind: .5; } .i2 { --ind: 1; } .i3 { --ind: 1.5; }
  .console__body { padding: 16px 14px 22px; }
  .console__meta { display: none; }
  .theme-toggle { padding: 0 12px; }
  .theme-toggle__label { display: none; }
  .awards { gap: 2px; }
  .award { padding: 10px 0; }
  .laurel { width: 23px; height: 48px; }
  .award__apple { width: 13px; height: 16px; }
  .award b { font-size: 11px; }
  .award small { font-size: 8.5px; }
  .stub { padding-left: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .l { animation: none; opacity: 1; }
  .cursor { animation: none; }
  * { transition: none !important; }
}
