/*
 * The "putty" theme: the site drawn like a PuTTY window. Same font, size and
 * weight as PuTTY's default (Courier New 10pt, regular), boxes drawn with thin
 * lines like its box-drawing characters, and everything sized in characters
 * (ch) and in 16px rows so it lines up like a character grid.
 *
 * Everything here applies only while <html data-theme="putty"> (see
 * assets/js/theme.js); style.css holds the classic theme.
 */

html[data-theme="putty"] {
  --color-border: #168a2f;
  --color-text-dim: #1fa03d;
  --font-mono: "Courier New", "Liberation Mono", Cousine, monospace;
  --radius: 0;
  --glow: none;
  --terminal-row: 16px;
  --terminal-text-width: 70ch;
  --terminal-sidebar-width: 26ch;
  --terminal-column-gap: 2ch;
  --terminal-box-padding-x: 1.5ch;
  --terminal-box-padding-y: 15px;
  --terminal-scrollbar-width: 8px;
  --terminal-scrollbar-gap: 8px;
  --terminal-window-margin: 24px;
  --terminal-window-min-height: 560px;
  font: 400 13.333px/var(--terminal-row) var(--font-mono);
  font-variant-ligatures: none;
}

html[data-theme="putty"] body {
  font: inherit;
  line-height: var(--terminal-row);
}

html[data-theme="putty"] .background {
  display: none;
}

/* The window: a double line frame with the domain in its top edge. */
html[data-theme="putty"] .layout {
  position: relative;
  grid-template-columns: var(--terminal-sidebar-width) var(--terminal-text-width);
  grid-template-areas:
    "side banner"
    "side content"
    "foot foot";
  grid-template-rows: auto minmax(0, 1fr) auto;
  column-gap: var(--terminal-column-gap);
  justify-content: center;
  width: calc(var(--terminal-sidebar-width) + var(--terminal-text-width) + var(--terminal-column-gap) + 6ch + 6px);
  height: max(var(--terminal-window-min-height), calc(100dvh - 2 * var(--terminal-window-margin)));
  min-height: 0;
  margin: var(--terminal-window-margin) auto;
  padding: 8px 3ch;
  border: 3px double var(--color-border);
}

html[data-theme="putty"] .layout::before {
  content: " " attr(data-title) " ";
  position: absolute;
  top: -10px;
  left: 3ch;
  background: var(--color-background);
  color: var(--color-accent);
  line-height: var(--terminal-row);
  white-space: pre;
}

html[data-theme="putty"] .main {
  display: contents;
}

/* Sidebar: boxes with their names in the top line. */
/* The window stays as tall as the view, so what does not fit scrolls inside it. */
html[data-theme="putty"] .sidebar {
  grid-area: side;
  position: static;
  height: auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--terminal-row);
  /* Room for the box titles that hang over the top edge. */
  padding: var(--terminal-row) 0 0;
  background: none;
  border: 0;
}

/* The sidebar only scrolls in a very short window, and then by wheel or keys. */
html[data-theme="putty"] .sidebar {
  scrollbar-width: none;
}

html[data-theme="putty"] .sidebar::-webkit-scrollbar {
  display: none;
}

/* The content's scrollbar is a fixed-width track in the gap between the cards and the window frame. */
html[data-theme="putty"] .content {
  scrollbar-gutter: stable;
}

html[data-theme="putty"] .content::-webkit-scrollbar {
  width: var(--terminal-scrollbar-width);
}

html[data-theme="putty"] .content::-webkit-scrollbar-track {
  background: rgba(34, 201, 74, 0.1);
  border-left: 1px solid var(--color-border);
}

html[data-theme="putty"] .content::-webkit-scrollbar-thumb {
  background: var(--color-text);
}

html[data-theme="putty"] .content::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent);
}

@supports not selector(::-webkit-scrollbar) {
  html[data-theme="putty"] .content {
    scrollbar-width: thin;
    scrollbar-color: var(--color-text) rgba(34, 201, 74, 0.1);
  }
}

html[data-theme="putty"] .avatar,
html[data-theme="putty"] .navigation,
html[data-theme="putty"] .sidebar-actions {
  position: relative;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}

html[data-theme="putty"] .avatar::before,
html[data-theme="putty"] .navigation::before,
html[data-theme="putty"] .sidebar-actions::before {
  position: absolute;
  top: -9px;
  left: 2ch;
  background: var(--color-background);
  color: var(--color-text-dim);
  line-height: var(--terminal-row);
  white-space: pre;
}

html[data-theme="putty"] .avatar::before {
  content: " " attr(data-title) " ";
}

html[data-theme="putty"] .navigation::before {
  content: " menu ";
}

html[data-theme="putty"] .sidebar-actions::before {
  content: " links ";
}

html[data-theme="putty"] .avatar {
  width: 100%;
  height: calc(13 * var(--terminal-row));
  padding: calc(var(--terminal-row) - 1px) 0;
}

html[data-theme="putty"] .avatar img,
html[data-theme="putty"] .avatar canvas {
  width: calc(11 * var(--terminal-row));
  height: calc(11 * var(--terminal-row));
  margin: 0 auto;
  border-radius: 50%;
}

html[data-theme="putty"] .navigation,
html[data-theme="putty"] .sidebar-actions {
  display: block;
  padding: calc(var(--terminal-row) - 1px) 1ch;
}

html[data-theme="putty"] .sidebar-actions:empty {
  display: none;
}

/* Menu rows: "  Label", with "> " in front of the selected one and the open page in inverse video. */
html[data-theme="putty"] .navigation a,
html[data-theme="putty"] .sidebar-actions .button {
  display: block;
  width: 100%;
  height: var(--terminal-row);
  padding: 0 1ch;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--color-text);
  font: inherit;
  line-height: var(--terminal-row);
  overflow: hidden;
  text-overflow: clip;
  text-decoration: none;
  white-space: pre;
}

html[data-theme="putty"] .navigation a::before,
html[data-theme="putty"] .sidebar-actions .button::before {
  content: "  ";
}

html[data-theme="putty"] .navigation a:hover,
html[data-theme="putty"] .navigation a:focus-visible,
html[data-theme="putty"] .sidebar-actions .button:hover,
html[data-theme="putty"] .sidebar-actions .button:focus-visible {
  border: 0;
  background: none;
  color: var(--color-accent);
}

html[data-theme="putty"] .navigation a.active,
html[data-theme="putty"][data-focus="menu"] .navigation a.selected.active {
  border: 0;
  background: var(--color-text);
  box-shadow: none;
  color: var(--color-background);
}

html[data-theme="putty"] .navigation a.external::after {
  content: "  ->";
  color: inherit;
}

/* Banner: the ASCII name in the grid font, with the tagline under it. */
html[data-theme="putty"] .banner {
  grid-area: banner;
  gap: 0;
  padding-top: var(--terminal-row);
  margin-bottom: var(--terminal-row);
}

html[data-theme="putty"] .banner-art {
  font: inherit;
  line-height: var(--terminal-row);
  text-shadow: none;
  overflow: visible;
}

html[data-theme="putty"] .banner-tagline {
  font: inherit;
  line-height: var(--terminal-row);
  color: var(--color-text);
}

html[data-theme="putty"] .content {
  grid-area: content;
  min-height: 0;
  width: auto;
  max-width: none;
  overflow-y: auto;
  /* Padding that is cancelled by the margin, so the cards' outer lines are not cut off.
     On the right it makes room for the scrollbar, inside the frame's padding. */
  margin: -1px calc(-1 * (var(--terminal-scrollbar-width) + var(--terminal-scrollbar-gap))) -1px -1px;
  padding: 1px var(--terminal-scrollbar-gap) 1px 1px;
  border: 0;
  background: none;
  box-shadow: none;
}

html[data-theme="putty"][data-focus="content"] .content {
  box-shadow: none;
}

html[data-theme="putty"] .footer {
  grid-area: foot;
  margin: 0;
  padding: var(--terminal-row) 0 0;
  font: inherit;
  line-height: var(--terminal-row);
  color: var(--color-text-dim);
}

/* Cards are boxes. */
html[data-theme="putty"] .card {
  padding: var(--terminal-box-padding-y) var(--terminal-box-padding-x);
  border-radius: 0;
  background: none;
}

html[data-theme="putty"] .card + .card {
  margin-top: var(--terminal-row);
}

html[data-theme="putty"] .grid > .card {
  margin-top: 0;
}

/* A card that only holds a grid of cards would draw a box around boxes. */
html[data-theme="putty"] .card:has(> .grid:only-child) {
  padding: 0;
  border: 0;
}

html[data-theme="putty"] .grid,
html[data-theme="putty"] .grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(30ch, 1fr));
  gap: var(--terminal-row) var(--terminal-column-gap);
}

/* Text: one size, one weight, blank rows between blocks. */
html[data-theme="putty"] h1,
html[data-theme="putty"] h2,
html[data-theme="putty"] h3 {
  margin: var(--terminal-row) 0;
  font-size: inherit;
  font-weight: 400;
  line-height: var(--terminal-row);
}

html[data-theme="putty"] .card > :first-child {
  margin-top: 0;
}

html[data-theme="putty"] p,
html[data-theme="putty"] ul,
html[data-theme="putty"] ol {
  margin: var(--terminal-row) 0;
}

html[data-theme="putty"] .card > :last-child {
  margin-bottom: 0;
}

html[data-theme="putty"] .command {
  margin: 0 0 var(--terminal-row);
  color: var(--color-text-dim);
}

html[data-theme="putty"] .command:has(+ .command-output) {
  margin-bottom: 0;
}

html[data-theme="putty"] .command-output {
  margin: 0 0 var(--terminal-row);
}

html[data-theme="putty"] strong,
html[data-theme="putty"] .label {
  font-weight: 400;
}

html[data-theme="putty"] ol li + li {
  margin-top: 0;
}

html[data-theme="putty"] ol {
  padding-left: 3ch;
}

html[data-theme="putty"] .tags {
  gap: 0 1ch;
  margin: var(--terminal-row) 0;
}

html[data-theme="putty"] .tag {
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: inherit;
  color: var(--color-text-dim);
}

html[data-theme="putty"] .tag.under-cursor {
  background: var(--color-text);
  color: var(--color-background);
}

html[data-theme="putty"] .tag::before {
  content: "[";
}

html[data-theme="putty"] .tag::after {
  content: "]";
}

html[data-theme="putty"] .project {
  gap: var(--terminal-row);
}

html[data-theme="putty"] .project > * {
  margin: 0;
}

html[data-theme="putty"] .project .card-link {
  margin-top: auto;
  padding-top: 0;
}

html[data-theme="putty"] .command-link {
  color: var(--color-text-dim);
  text-decoration: none;
}

html[data-theme="putty"] .command-link:hover,
html[data-theme="putty"] .command-link.under-cursor {
  color: var(--color-text);
  text-decoration: none;
}

/* Buttons in pages read as [ label ]. */
html[data-theme="putty"] .content .button {
  display: inline;
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: inherit;
}

html[data-theme="putty"] .content .button::before {
  content: "[ ";
}

html[data-theme="putty"] .content .button::after {
  content: " ]";
}

html[data-theme="putty"] .skill,
html[data-theme="putty"] .timeline-item {
  border-radius: 0;
  font-size: inherit;
}

html[data-theme="putty"] .skill::after {
  height: 8px;
  border-radius: 0;
}

html[data-theme="putty"] .timeline-item .when {
  font-size: inherit;
}

/* Narrow windows: the boxes stack and the window frame is dropped to the screen edge. */
@media (max-width: 960px) {
  html[data-theme="putty"] .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "side"
      "banner"
      "content"
      "foot";
    --terminal-window-margin: 12px;
    --terminal-window-min-height: 0px;
    width: auto;
    height: auto;
    min-height: calc(100dvh - 2 * var(--terminal-window-margin));
    padding: 8px 1.5ch;
  }

  html[data-theme="putty"] .sidebar {
    overflow-y: visible;
    margin-bottom: var(--terminal-row);
  }

  html[data-theme="putty"] .content {
    overflow-y: visible;
    scrollbar-gutter: auto;
    margin: 0;
    padding: 0;
  }

  html[data-theme="putty"] .banner {
    align-items: flex-start;
  }

  html[data-theme="putty"] .banner-art {
    font-size: clamp(5px, 1.9vw, 13.333px);
    line-height: 1.2;
  }

  html[data-theme="putty"] .banner-tagline {
    text-align: left;
  }

  html[data-theme="putty"] .navigation,
  html[data-theme="putty"] .sidebar-actions {
    flex-direction: column;
  }
}
