/* JetBrains Mono (OFL-1.1), latin subset, self-hosted by scripts/fonts.ts */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-600-normal.woff2") format("woff2");
}

/* Shell view: one dark zsh window. Also the fallback layout for wip views,
   which is why everything keys off data-layout, never data-view. */

html[data-layout="shell"] {
  --bg: #0e1116;
  --fg: #d7dde6;
  --accent: #7ee787;
  --muted: #8b949e;
  --link: #79c0ff;
  --cyan: #56d4dd; /* 10.7:1 on --bg */
  --heading: #f2cc60;
  --desk: #05070a;
  --chrome: #161b22;
  --border: #30363d;
  --dot-close: #ff5f57;
  --dot-min: #febc2e;
  --dot-max: #28c840;
  --font: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html[data-layout="shell"] {
  background: var(--desk);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;

  & *,
  & *::before,
  & *::after {
    box-sizing: border-box;
  }

  & body {
    margin: 0;
    padding: 24px 16px;
    overflow-wrap: anywhere;
  }

  & a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  & a:hover,
  & a:focus-visible {
    color: var(--accent);
  }

  & :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  & h1,
  & h2,
  & h3 {
    color: var(--heading);
    font-size: 1em;
    font-weight: 600;
    margin: 1.4em 0 0.2em;
  }

  & h1::before {
    content: "# ";
  }

  & h2::before {
    content: "## ";
  }

  & h3::before {
    content: "### ";
  }

  & p,
  & ul,
  & ol,
  & dl {
    margin: 0 0 1em;
  }

  & time {
    color: var(--muted);
  }

  /* ---- window chrome ---- */

  & .shell-window {
    max-width: 90ch;
    margin: 0 auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }

  & .shell-titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--chrome);
  }

  & .shell-dots {
    display: flex;
    flex: none;
    gap: 6px;
  }

  & .shell-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--dot-close);
  }

  & .shell-dots span:nth-child(2) {
    background: var(--dot-min);
  }

  & .shell-dots span:nth-child(3) {
    background: var(--dot-max);
  }

  & .shell-title {
    flex: 1;
    min-width: 0;
    color: var(--muted);
    text-align: center;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  & .shell-notice {
    margin: 0;
    padding: 4px 16px;
    color: var(--heading);
    border-bottom: 1px dotted var(--border);
  }

  & .shell-screen {
    padding: 16px;
    min-width: 0;
  }

  & .shell-prompt {
    margin: 0 0 1em;
  }

  & .shell-screen > .shell-prompt:last-child {
    margin: 1.4em 0 0;
  }

  & .shell-user {
    color: var(--accent);
  }

  & .shell-cwd {
    color: var(--link);
  }

  & .shell-command {
    color: var(--fg);
  }

  & .shell-cursor {
    display: inline-block;
    width: 1ch;
    height: 1.2em;
    vertical-align: text-bottom;
    background: var(--fg);
    animation: shell-blink 1s steps(1) infinite;
  }

  /* ---- CV ---- */

  /* Portrait: the colour source, floated beside the name. */
  & :is(.c-cv-summary, .c-intro):has(> .c-portrait) {
    display: flow-root;
  }

  & .c-portrait {
    float: right;
    width: 96px;
    height: 96px;
    margin: 0 0 1em 2ch;
    border: 1px solid var(--muted);
  }

  & section[aria-label]::before {
    display: block;
    margin-top: 1.6em;
    color: var(--muted);
    font-variant-ligatures: none;
    content: "<!-- " attr(aria-label) " -->";
  }

  & .c-cv-summary h1 {
    margin-top: 0;
  }

  & .c-cv-tagline {
    margin-bottom: 0.2em;
  }

  & .c-cv-titlelocation {
    margin-bottom: 0.2em;
    color: var(--accent);
  }

  & .c-cv-location::before {
    content: ", ";
  }

  & .c-cv-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0 2ch;
    padding: 0;
    list-style: none;
  }

  & .c-role-org,
  & .c-earlier-org,
  & .c-leadership-org {
    margin: 0 0 0.2em;
    color: var(--accent);
  }

  & .c-role-dates,
  & .c-role-location {
    margin: 0;
    color: var(--muted);
  }

  & .c-role-summary,
  & .c-earlier-summary,
  & .c-leadership-summary {
    margin-top: 0.4em;
  }

  & .c-patents ul,
  & .c-education ul {
    padding-left: 2ch;
  }

  & .c-patent > span,
  & .c-patent > time,
  & .c-education-item > span {
    display: block;
  }

  & .c-patent-number,
  & .c-education-award {
    color: var(--accent);
  }

  & .c-skills dt {
    margin-top: 0.6em;
    color: var(--heading);
  }

  & .c-skills dt::before {
    content: "- ";
  }

  & .c-skills dd {
    margin: 0 0 0 2ch;
  }

  /* ---- posts ---- */

  & .c-posts {
    padding: 0;
    list-style: none;
  }

  & .c-post-item {
    margin-bottom: 1.2em;
  }

  & .c-post-item > time {
    display: block;
  }

  & .c-post-excerpt {
    margin: 0.2em 0;
  }

  & .c-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5ch;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  & .c-post-tags a::before {
    content: "#";
  }

  & .c-post-header {
    margin-bottom: 1.6em;
  }

  & .c-post-header h1 {
    margin-top: 0;
  }

  & .c-post-content {
    min-width: 0;
  }

  & .c-post-content pre {
    max-width: 100%;
    margin: 0 0 1em;
    padding: 12px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font);
    font-size: 0.9em;
    overflow-wrap: normal;
  }

  & .c-post-content code {
    font-family: var(--font);
  }

  & .c-post-content :not(pre) > code {
    color: var(--accent);
  }

  & .c-post-content blockquote {
    margin: 0 0 1em;
    padding-left: 2ch;
    border-left: 2px solid var(--border);
    color: var(--muted);
  }

  & .c-post-content img {
    max-width: 100%;
    height: auto;
  }

  & .c-post-series {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px dotted var(--border);
  }

  & .c-plain-link {
    margin-top: 1.6em;
  }

  & .c-plain-link::before {
    color: var(--muted);
    content: "% cat cv.txt  # ";
  }

  & .c-empty::before {
    content: "ls: " attr(data-dir) ": ";
  }

  /* ---- prompts between outputs, and the closing cd .. or ls -la ---- */

  & .shell-screen > :not(.shell-prompt) + .shell-prompt {
    margin-top: 1.4em;
  }

  & .shell-prompt-cd {
    margin-bottom: 0;
  }

  & .shell-prompt-cd a {
    white-space: nowrap;
  }

  & .shell-screen > .shell-prompt-cd + .shell-prompt:last-child {
    margin-top: 0;
  }

  & .c-role-excerpt,
  & .c-earlier-excerpt,
  & .c-leadership-excerpt {
    margin-top: 0.4em;
  }

  /* ---- home: focus ---- */

  & :is(.c-focus, .c-focus-items) {
    padding: 0;
    list-style: none;
  }

  & .c-focus-group + .c-focus-group {
    margin-top: 1em;
  }

  & .c-focus-item + .c-focus-item {
    margin-top: 0.6em;
  }

  & .c-focus-excerpt {
    margin: 0;
  }

  /* ---- ls -la (home, /cv/, /work/) ---- */

  /* One grid shared by every line (subgrid), so modes, names and the
     target/note column align. */
  & .c-dir {
    display: grid;
    grid-template-columns: max-content max-content 1fr;
    column-gap: 2ch;
    padding: 0;
    list-style: none;
  }

  & .c-dir > li {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
  }

  & .c-dir-mode {
    color: var(--muted);
    font-variant-ligatures: none;
  }

  & .c-dir-name {
    justify-self: start;
    text-decoration: none;
  }

  & .c-dir-name:hover,
  & .c-dir-name:focus-visible {
    text-decoration: underline;
  }

  & .c-dir-dir .c-dir-name {
    color: var(--link);
  }

  & .c-dir-file .c-dir-name {
    color: var(--fg);
  }

  & .c-dir-exec .c-dir-name {
    color: var(--accent);
  }

  & .c-dir-link .c-dir-name,
  & .c-dir-target {
    color: var(--cyan);
  }

  & .c-dir-target {
    font-variant-ligatures: none;
  }

  /* Wrap inside the URL, never between - and >. */
  & .c-dir-arrow {
    white-space: nowrap;
  }

  & .c-dir-note {
    color: var(--muted);
  }

  & .c-dir-note::before {
    content: "# ";
  }

  /* Notes keep their two-space column gaps (the /work/ listing). */
  & .c-dir-note {
    white-space: pre-wrap;
  }

  /* ---- work item ---- */

  & .c-work-title {
    margin-top: 0;
  }

  & .c-work-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1ch;
    margin: 0 0 1.4em;
  }

  & .c-work-meta dt {
    color: var(--muted);
  }

  & .c-work-meta dt::after {
    content: ":";
  }

  & .c-work-meta dd {
    margin: 0;
    min-width: 0;
  }

  & .c-work-link,
  & .c-work-link a {
    color: var(--cyan);
  }

  & .c-work-link {
    font-variant-ligatures: none;
  }

  & .c-work-link a {
    text-decoration: none;
  }

  & .c-work-link a:hover,
  & .c-work-link a:focus-visible {
    text-decoration: underline;
  }

  & .c-work-body img {
    max-width: 100%;
    height: auto;
  }

  /* ---- contact: ./contact as a transcript ---- */

  & .c-step {
    min-width: 0; /* fieldsets default to min-content and overflow phones */
    margin: 0 0 1em;
    padding: 0;
    border: 0;
  }

  & .c-step[hidden] {
    display: none;
  }

  & .c-step > label,
  & .c-step > legend {
    display: block;
    padding: 0;
    color: var(--fg);
  }

  & .c-step :is(input:not([type="radio"]), textarea) {
    display: block;
    width: 100%;
    max-width: 60ch;
    padding: 2px 0;
    background: transparent;
    color: var(--fg);
    border: 0;
    border-bottom: 1px solid var(--muted);
    border-radius: 0;
    font: inherit;
  }

  & .c-step textarea {
    resize: vertical;
  }

  & .c-step :is(input, textarea, button):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  & .c-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2em 2ch;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* The radio stays focusable for arrow keys; its token shows the state. */
  & .c-menu-item {
    position: relative;
    cursor: pointer;
  }

  & .c-menu-item input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
  }

  & .c-menu-item input:checked + span {
    background: var(--fg);
    color: var(--bg);
  }

  & .c-menu-item input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  & .c-step-send button {
    margin-right: 2ch;
    padding: 0 1ch;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 0;
    font: inherit;
    cursor: pointer;
  }

  & .c-step-send button:disabled {
    color: var(--muted);
    border-color: var(--muted);
    cursor: not-allowed;
  }

  & .c-contact-out {
    margin: 1em 0 0;
    font: inherit;
    white-space: pre-wrap;
  }

  & .c-contact-out[data-state="ok"] {
    color: var(--accent);
  }

  & .c-contact-out[data-state="error"] {
    color: var(--heading);
  }

  & .c-contact-progress {
    color: var(--muted);
  }

  & .c-step-hint {
    margin: 0.2em 0 0;
    color: var(--muted);
    font-size: 0.9em;
  }

  & .c-step-hint::before {
    content: "# ";
  }

  & .c-contact-trap {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Phones: the target or note wraps under the name. */
  @media (max-width: 48em) {
    & .c-dir {
      grid-template-columns: max-content 1fr;
    }

    & :is(.c-dir-target, .c-dir-note) {
      grid-column: 2;
    }
  }
}

@keyframes shell-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-layout="shell"] .shell-cursor {
    animation: none;
  }
}
