/* Page layout for the single-page site: fixed icon sidebar, article pane, landing tiles, modals. */
:root {
  --lite-sidebar-w: 52px;
  /* Height of the sidebar when it turns into a top bar on phones. */
  --lite-topbar-h: 48px;
}

html { height: 100%; }
/* Undo reset.css's fixed-height, overflow:hidden body so the page scrolls. */
body {
  height: auto;
  min-height: 100%;
  overflow: auto;
  background: var(--window-body-bg);
  color: var(--text);
}
/* reset.css disables selection on body; re-enable it for article text. */
.lite-article, .lite-article * {
  user-select: text;
}

.lite-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--lite-sidebar-w);
  background: var(--platinum);
  border-right: 1px solid var(--platinum-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  z-index: var(--z-sidebar);
  font-family: var(--font-chicago);
}
.lite-sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  align-items: center;
}
/* Pushes the footer (Contact) list to the bottom of the sidebar. */
.lite-sidebar__spacer { flex: 1; }
.lite-sidebar__list--brand {
  border-bottom: 1px solid var(--platinum-shadow);
  padding-bottom: 6px;
  margin: 0 6px 6px;
  width: calc(100% - 12px);
}
.lite-sidebar__list--footer {
  border-top: 1px solid var(--platinum-shadow);
  padding-top: 6px;
  width: calc(100% - 12px);
  margin: 0 6px;
}
.lite-sidebar__separator {
  list-style: none;
  width: calc(100% - 18px);
  height: 0;
  margin: 4px 9px;
  border-top: 1px solid var(--platinum-shadow);
}

.lite-sidebar__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 4px;
  border: 0;
  background: transparent;
  cursor: default;
  color: var(--text);
  text-decoration: none;
}
.lite-sidebar__icon {
  width: 28px;
  height: 28px;
  display: block;
}
/* Icon SVGs are drawn in black (#000); invert them for the dark theme. */
:root.theme-dark .lite-sidebar__icon {
  filter: invert(1);
}
.lite-sidebar__btn:hover,
.lite-sidebar__btn.is-active {
  background: var(--platinum-shadow);
}

/* Tooltip from data-label; fades in after a 0.1s hover delay. */
.lite-sidebar__btn[data-label]::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--platinum);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow:
    inset 1px 1px 0 var(--platinum-highlight),
    inset -1px -1px 0 var(--platinum-shadow),
    2px 2px 0 rgba(0,0,0,0.35);
  padding: 2px 8px;
  font-family: var(--font-chicago);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s linear 0.1s;
  z-index: var(--z-tooltip);
}
/* Hover tooltips only where a real pointer can hover: touch screens emulate :hover on tap and
   keep it until the next tap, so the label stuck on (e.g. a phone in landscape). */
@media (hover: hover) {
  .lite-sidebar__btn[data-label]:hover::after { opacity: 1; }
}
.lite-sidebar__btn[data-label]:focus-visible::after {
  opacity: 1;
}

/* Keyboard focus ring in the theme's link colour, so it shows on both light and dark. */
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.lite-main {
  margin-left: var(--lite-sidebar-w);
  padding: 16px;
  min-height: 100vh;
  box-sizing: border-box;
}

.lite-article {
  background: var(--window-body-bg);
  margin: 0 auto;
  /* 100vh minus .lite-main's 16px top and bottom padding. */
  min-height: calc(100vh - 32px);
}
.lite-article__pending {
  font-family: var(--font-chicago);
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 16px;
}
.lite-article a:has(> img) {
  text-decoration: none;
  color: inherit;
}

.codex__toolbar-btn {
  cursor: default;
}

.lite-landing__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.lite-landing__section {
  /* Makes the section a size container for the @container rule below. */
  container-type: inline-size;
}
.lite-landing__grid--projects {
  grid-template-columns: repeat(4, 1fr);
}
/* 4 or 2 columns, never 3, so four games never leave an orphan tile. Two columns once */
/* four tiles would drop under ~130px each: 4 x 130 + 3 x 12px gap = 556px of column. */
@container (max-width: 556px) {
  .lite-landing__grid--projects {
    grid-template-columns: repeat(2, 1fr);
  }
}
.lite-landing__tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  box-shadow:
    inset 1px 1px 0 var(--platinum-highlight),
    inset -1px -1px 0 var(--platinum-shadow);
  cursor: default;
  color: var(--text);
  font-family: var(--font-chicago);
  font-size: 12px;
  text-align: center;
}
.lite-landing__tile:hover {
  background: var(--platinum);
}
.lite-landing__tile:active {
  box-shadow:
    inset 1px 1px 0 var(--platinum-shadow),
    inset -1px -1px 0 var(--platinum-highlight);
}
.lite-landing__tile-icon {
  width: 56px;
  height: 56px;
  display: block;
}
/* Icon SVGs are drawn in black (#000); invert them for the dark theme. */
:root.theme-dark .lite-landing__tile-icon {
  filter: invert(1);
}
.lite-landing__tile-label {
  font-family: var(--font-chicago);
  font-size: 12px;
  color: var(--text);
  line-height: 1.25;
}

.lite-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lite-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.lite-modal__window {
  position: relative;
  background: var(--platinum);
  border: 1px solid #000;
  box-shadow:
    inset 1px 1px 0 var(--platinum-highlight),
    inset -1px -1px 0 var(--platinum-shadow),
    3px 3px 0 rgba(0, 0, 0, 0.45);
  width: calc(100% - 32px);
  max-width: 480px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  font-family: var(--font-chicago);
}
.lite-modal__titlebar {
  display: grid;
  /* Equal 18px side columns keep the title centred; the right one is an empty spacer span. */
  grid-template-columns: 18px 1fr 18px;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  background:
    repeating-linear-gradient(
      to bottom,
      var(--titlebar-stripe-bg) 0 2px,
      var(--titlebar-stripe-fg) 2px 3px
    );
  border-bottom: 1px solid #000;
  user-select: none;
}
.lite-modal__title {
  font-family: var(--font-chicago);
  font-size: 12px;
  background: var(--platinum);
  padding: 1px 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lite-modal__close {
  width: 13px;
  height: 13px;
  background: var(--platinum);
  border: 1px solid #000;
  box-shadow:
    inset 1px 1px 0 var(--platinum-highlight),
    inset -1px -1px 0 var(--platinum-shadow);
  cursor: default;
  padding: 0;
  justify-self: start;
}
.lite-modal__close:hover {
  background: var(--platinum-shadow);
}
.lite-modal__close:active {
  box-shadow:
    inset 1px 1px 0 var(--platinum-shadow),
    inset -1px -1px 0 var(--platinum-highlight);
}
.lite-modal__body {
  background: var(--window-body-bg);
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.lite-lightbox__window {
  max-width: min(1200px, calc(100% - 32px));
  width: auto;
}
.lite-lightbox__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.lite-lightbox__img {
  display: block;
  max-width: 100%;
  /* Approximate room for the titlebar, caption, Prev/Next row and the window margins. */
  max-height: calc(100vh - 160px);
  border: 1px solid #000;
}
.lite-lightbox__caption {
  font-family: var(--font-chicago);
  font-size: 11px;
  color: var(--text-dim);
  margin: 0;
  max-width: 70ch;
  text-align: center;
}
.lite-lightbox__nav {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  border-top: 1px solid #000;
}
/* Same exclusions as the click handler in lightbox.js. */
.lite-article img:not(a img):not(button img) { cursor: zoom-in; }

/* Phones: the sidebar becomes a fixed top bar (Home left, projects, Contact right), the article
   goes full width, and side-by-side layouts stack. 640px is roughly where the 52px rail plus
   page padding leave too little reading width. */
@media (max-width: 640px) {
  .lite-sidebar {
    right: 0;
    bottom: auto;
    width: auto;
    height: var(--lite-topbar-h);
    flex-direction: row;
    padding: 0 6px;
    border-right: 0;
    border-bottom: 1px solid var(--platinum-shadow);
    overflow-x: auto;
  }
  .lite-sidebar__list {
    flex-direction: row;
    width: auto;
  }
  .lite-sidebar__list--brand {
    border-bottom: 0;
    border-right: 1px solid var(--platinum-shadow);
    padding: 0 6px 0 0;
    margin: 0 6px 0 0;
    width: auto;
  }
  .lite-sidebar__list--footer {
    border-top: 0;
    border-left: 1px solid var(--platinum-shadow);
    padding: 0 0 0 6px;
    margin: 0 0 0 6px;
    width: auto;
  }
  .lite-sidebar__separator {
    width: 0;
    height: 28px;
    margin: 0 4px;
    border-top: 0;
    border-left: 1px solid var(--platinum-shadow);
  }
  /* No hover on touch screens, and the labels would cover the article anyway. */
  .lite-sidebar__btn[data-label]::after { display: none; }

  .lite-main {
    margin-left: 0;
    padding: var(--lite-topbar-h) 0 0;
  }
  .lite-article { min-height: 0; }
  .codex {
    --codex-pad-x: 16px;
    --codex-pad-y: 16px;
  }
  /* Titles start smaller on phones; viewer-blocks.js steps them down further to fit one line. */
  .codex .viewer__title { font-size: 24px; }
  /* The sticky article toolbar parks under the fixed top bar instead of behind it. */
  .codex__toolbar { top: var(--lite-topbar-h); }

  .md-aside { grid-template-columns: 1fr; }
  .md-aside > .md-figure img {
    flex: none;
    height: auto;
    min-height: 0;
    object-fit: contain;
  }
}
