/*
 * Component styles for the redesign, mapped from the Figma components:
 * shell, portrait, theme picker, segmented controls, menu, hero, content
 * header, prose, and footer. All colours come from the theme tokens.
 */

/* ---------- Shell (content column: 1140px inside 96px margins) ---------- */
.shell {
  max-width: var(--grid-max-width);
  margin-inline: auto;
  padding-inline: var(--grid-margin);
}

/* Content-width horizontal rule */
.rule,
.hero__inner::after,
.content-header__inner::after {
  border: 0;
  border-top: 0.5px solid
    color-mix(in srgb, var(--color-accent) 60%, transparent);
}

.hero__inner::after,
.content-header__inner::after {
  content: "";
  height: 1px;
  position: absolute;
  bottom: 0;
  left: var(--grid-margin);
  right: var(--grid-margin);
}

@media (max-width: 768px) {
  :root {
    --grid-margin: var(--space-m);
  }
}

/* ---------- Portrait (vector halftone, tinted by theme) ---------- */
.portrait {
  display: inline-block;
  position: relative;
  border-radius: 50%;
  background: var(--photo-bg);
  overflow: hidden;
  flex: none;
  transition: background-color var(--theme-transition-duration)
    var(--theme-transition-ease);
}
.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--photo-fg);
  -webkit-mask: url("/img/portrait-halftone.svg") center / 100% 100% no-repeat;
  mask: url("/img/portrait-halftone.svg") center / 100% 100% no-repeat;
  transition: background-color var(--theme-transition-duration)
    var(--theme-transition-ease);
}
.portrait--large {
  width: 120px;
  height: 120px;
}
.portrait--small {
  width: 24px;
  height: 24px;
}

/* ---------- Small button (Figma "Small Button") ---------- */
.small-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xxs) 9px;
  border: 0;
  border-radius: 3px;
  background: var(--button-bg);
  color: var(--button-text);
  font: var(--type-caption);
  text-transform: uppercase;
  font-feature-settings:
    "lnum" 1,
    "pnum" 1;
  cursor: pointer;
  min-width: fit-content;
}

.small-button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: -1px;
}

.small-button svg {
  width: 12px;
  height: 12px;
  display: block;
}

/* ---------- Theme picker ---------- */
.theme-picker {
  display: flex;
  align-items: flex-end;
  gap: var(--space-s);
}
.theme-picker__controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  width: 284px;
}
.theme-picker__heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
}
.theme-picker__title,
.theme-picker__status {
  margin: 0;
  font: var(--type-caption);
  text-transform: uppercase;
  font-feature-settings:
    "lnum" 1,
    "pnum" 1;
  color: var(--color-text);
}
.theme-picker__title {
  font-weight: var(--weight-bold);
}

.theme-picker__location {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: stretch;
}
.theme-picker__location input {
  font: var(--type-caption);
  text-transform: uppercase;
  font-feature-settings:
    "lnum" 1,
    "pnum" 1;
  color: var(--color-text);
  background: transparent;
  border: 0;
  padding: var(--space-xxs) var(--space-xs);
  min-width: 2em;
  width: 100%;
}
.theme-picker__location input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

.theme-picker__city {
  flex: 1;
  display: flex;
  align-items: stretch;
  border: 0.5px solid var(--color-accent);
  border-radius: 3px;
  min-width: 3em;
}
.theme-picker__city .small-button {
  border-radius: 0;
}

.theme-picker__coords {
  display: flex;
}
.theme-picker__coords input {
  width: 64px;
  text-align: center;
  border: 0.5px solid var(--color-accent);
}
.theme-picker__coords input:first-child {
  border-radius: 3px 0 0 3px;
  margin-right: -0.5px;
}
.theme-picker__coords input:last-child {
  border-radius: 0 3px 3px 0;
}

.theme-picker__options {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.theme-picker__globe {
  width: 64px;
  flex: none;
}
.theme-picker__globe globe-locator {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  color: var(--globe-line);
}

/* ---------- Segmented control ---------- */
.segmented {
  display: flex;
  gap: var(--space-xxs);
  padding: var(--space-xxs);
  border: 0.5px solid var(--color-accent);
  border-radius: 3px;
}
.segmented button {
  padding: 0 var(--space-xs);
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: var(--color-text);
  font: var(--type-caption);
  text-transform: uppercase;
  cursor: pointer;
}
.segmented button.is-selected {
  background: var(--ui-selected-bg);
  color: var(--ui-selected-text);
  font-weight: var(--weight-bold);
  box-shadow: inset 0 -2px 0 var(--color-accent);
}
.segmented button:focus-visible {
  outline-color: var(--color-accent);
}

/* ---------- Collapsed theme picker (content pages) ---------- */
.theme-picker-collapsed {
  position: relative;
}
.theme-picker-collapsed > summary {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  font: var(--type-caption);
  text-transform: uppercase;
  font-feature-settings:
    "lnum" 1,
    "pnum" 1;
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-xxs) var(--space-xs);
  border: 0.5px solid var(--color-accent);
  border-radius: 3px;
}
.theme-picker-collapsed > summary::-webkit-details-marker {
  display: none;
}
.theme-picker-collapsed__current {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.theme-picker-collapsed__label {
  font-weight: var(--weight-bold);
}
.theme-picker-collapsed__caret {
  transition: rotate 150ms ease;
}
.theme-picker-collapsed[open] .theme-picker-collapsed__caret {
  rotate: 180deg;
}
.theme-picker-collapsed > .theme-picker {
  position: absolute;
  top: calc(100% + var(--space-xs));
  right: 0;
  z-index: 10;
  background: var(--card-bg);
  border: 0.5px solid var(--color-accent);
  border-radius: 3px;
  padding: var(--space-s);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--color-text) 12%, transparent);
  width: 400px;
  max-width: calc(100vw - calc(var(--grid-margin) * 2));
}
.theme-picker-collapsed__icon {
  display: inline-flex;
  color: var(--color-accent);
}
.theme-picker-collapsed__icon .theme-icon {
  width: 16px;
  height: 16px;
  display: none;
}
/* Show only the icon matching the active theme. */
[data-theme="clear-day"] .theme-icon--clear-day,
[data-theme="clear-twilight"] .theme-icon--clear-twilight,
[data-theme="clear-night"] .theme-icon--clear-night,
[data-theme="cloudy-day"] .theme-icon--cloudy-day,
[data-theme="cloudy-twilight"] .theme-icon--cloudy-twilight,
[data-theme="cloudy-night"] .theme-icon--cloudy-night {
  display: block;
}
.theme-picker__close {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  display: inline-flex;
  padding: var(--space-xxs);
  border: 0;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}
.theme-picker__close:hover {
  color: var(--color-link);
}

/* ---------- Menu ---------- */
.site-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}
.site-menu a {
  display: block;
  position: relative;
  font: var(--type-body);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  text-decoration: none;
}
.site-menu a:hover {
  color: var(--color-link);
}
.site-menu a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--space-s));
  top: 2px;
  bottom: 2px;
  width: 3px;
  background: var(--color-accent);
}
.site-menu__short {
  display: none;
}

@media (max-width: 768px) {
  .site-menu ul {
    flex-direction: row;
    flex-wrap: wrap;
    column-gap: var(--space-s);
  }
  .site-menu__long {
    display: none;
  }
  .site-menu__short {
    display: inline;
  }
  .site-menu a {
    padding-block: var(--space-xs);
  }
  .site-menu a[aria-current="page"]::before {
    display: none;
  }
  .site-menu a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-underline-offset: 6px;
  }
}

/* ---------- Hero (homepage) ---------- */
.hero {
  background: var(--bg-gradient-hero);
}
.hero__inner {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-m);
  min-height: 348px;
  padding-top: var(--space-xxl);
  padding-bottom: 28px;
}
.hero__title {
  display: flex;
  align-items: center;
  gap: var(--space-m);
}
.hero__wordmark {
  margin: 0;
  font: var(--type-h1);
  color: var(--color-accent);
  text-shadow: 2px 3px 0 var(--letter-shadow);
}
.hero__tagline {
  margin: 0;
  font: var(--type-h5);
  color: var(--color-text);
  text-wrap: balance;
}
.hero__picker {
  padding-bottom: var(--space-xxs);
}

.home-main {
  display: grid;
  grid-template-columns: 180px minmax(0, 756px);
  column-gap: var(--space-s);
  row-gap: var(--space-l);
  padding-bottom: var(--space-xl);
}
.home-main::before {
  content: "";
  grid-column: 1 / -1;
}

@media (max-width: 389px) {
  .hero__title {
    flex-wrap: wrap;
    flex-basis: content;
  }

  .hero__text {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .hero__title {
    gap: var(--space-s);
  }
}

@media (max-width: 1064px) {
  .theme-picker {
    flex-wrap: wrap;
  }
}

@media (max-width: 900px) {
  .hero__inner {
    flex-direction: column;
    align-items: stretch;
    padding-top: var(--space-xl);
  }
  .hero__title {
    flex-direction: row-reverse;
    justify-content: space-between;
  }
  .portrait--large {
    width: 72px;
    height: 72px;
  }
  .hero__wordmark {
    font-size: 3.75rem;
    line-height: 1.2;
  }
  .home-main {
    grid-template-columns: 1fr;
    row-gap: var(--space-m);
  }
  /* Fit the picker inside the mobile content column (Figma "Mobile" frame). */
  .theme-picker {
    gap: var(--space-s);
  }
  .theme-picker__controls {
    width: auto;
    flex: 1;
  }
}

/* ---------- Content header (content pages) ----------
 * The sky fade on content pages is subtler than the homepage hero: a 180px
 * band offset 78px above the top of the page, so only its lower ~102px
 * fades into view (matches the Figma "header bg" at y=-78, h=180). */
.content-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

.content-header::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -40px;
  height: 160px;
  background: var(--bg-gradient-content);
  z-index: -1;
  pointer-events: none;
}

@media (max-width: 768px) {
  .content-header::before {
    height: var(--bg-gradient-content-visible-height);
  }
}

.content-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  min-height: 48px;
  padding-block: var(--space-xs);
}
.content-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-s);
  text-decoration: none;
}
.content-header__wordmark {
  font: var(--type-h4);
  font-family: var(--font-display);
  color: var(--color-accent);
  text-shadow: 1px 1px 0 var(--letter-shadow);
}

.content-main {
  display: grid;
  grid-template-columns: 180px minmax(0, 948px);
  column-gap: var(--space-s);
  padding-top: var(--space-xl);
}
.content-main__menu {
  padding-top: var(--space-xxl);
}
.content-main__body h1 {
  color: var(--color-text);
  margin-bottom: var(--space-m);
  font: var(--type-h2);
}

@media (max-width: 768px) {
  .content-main {
    grid-template-columns: 1fr;
    row-gap: var(--space-m);
    padding-top: var(--space-s);
  }
  .content-main__menu {
    padding-top: var(--space-s);
  }
}

/* ---------- Prose ---------- */
.prose {
  max-width: 756px;
}
.prose a {
  color: var(--color-link);
}
.prose strong a,
.prose a strong {
  text-decoration: underline;
}

/* ---------- Work entries (My work page) ---------- */
.work-rule {
  margin-block: var(--space-m);
}
.work-entry {
  display: grid;
  grid-template-columns: var(--space-xxl) minmax(0, 660px);
}

.work-entry__body {
  display: flex;
  flex-direction: column;
  row-gap: var(--space-m);
}

.work-entry__body p {
  margin-bottom: 0;
}

.work-entry__logo {
  margin-left: var(--space-m);
  width: 36px;
  height: 36px;
  display: block;
}
.work-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}
@media (max-width: 768px) {
  .work-entry {
    grid-template-columns: 36px 1fr;
    column-gap: var(--space-s);
    row-gap: var(--space-s);
  }

  .work-entry__logo {
    margin-left: 0;
  }
}

/* ---------- Cards ---------- */
.card-double {
  margin: 0;
  max-width: 660px;
  border: 0.5px solid var(--color-bg-highlight);
  border-radius: 6px;
  background: var(--card-bg);
  padding: 1px;
  filter: drop-shadow(3px 3px 0 rgb(0 0 0 / 0.1));
}
.card-double__inner {
  display: flex;
  border: 4px solid var(--card-bg);
  border-radius: 6px;
  background: var(--card-bg);
  overflow: hidden;
}
.card-double img {
  width: 314px;
  height: 183px;
  object-fit: cover;
  object-position: left top;
  flex: none;
  display: block;
}
.card-double figcaption {
  display: flex;
  align-items: flex-end;
  padding: var(--space-s);
  font: var(--type-caption);
  font-weight: var(--weight-regular);
  color: var(--color-text);
}
.card-double figcaption p {
  margin: 0;
}
.card-double figcaption strong {
  font-weight: var(--weight-bold);
}
.card-double figcaption a {
  color: var(--color-text);
}
@media (max-width: 1023px) {
  .card-double__inner {
    flex-direction: column;
  }
  .card-double img {
    width: 100%;
    height: auto;
    aspect-ratio: 314 / 183;
  }
}

.card-image {
  margin: 0;
  max-width: 324px;
  border: 0.5px solid var(--color-bg-highlight);
  border-radius: 6px;
  background: var(--card-bg);
  padding: 1px;
  filter: drop-shadow(3px 3px 0 rgb(0 0 0 / 0.1));
}
.card-image__inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 4px solid var(--card-bg);
  border-radius: 6px;
  background: var(--card-bg);
  overflow: hidden;
  padding: 8px;
}
.card-image img {
  width: 100%;
  height: 158px;
  object-fit: cover;
  object-position: left top;
  display: block;
}
.card-image figcaption {
  font: var(--type-caption);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}
.card-image figcaption a {
  color: var(--color-link);
}
.card-image--wide {
  max-width: 660px;
  margin-top: var(--space-l);
}
.card-image--wide img {
  height: auto;
  max-height: 360px;
}

/* ---------- Case study pages ---------- */
.case-study__back {
  margin: 0 0 var(--space-l);
  font: var(--type-caption);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
}
.case-study__back a {
  color: var(--color-link);
  text-decoration: none;
}
.case-study__back a:hover {
  text-decoration: underline;
}
.case-study__kicker {
  margin: 0 0 var(--space-xs);
  font: var(--type-h5);
  text-transform: uppercase;
  color: var(--color-text);
}
.case-study__title {
  font: var(--type-h2);
}
.case-study {
  display: grid;
  grid-template-columns: minmax(0, 660px) minmax(0, 372px);
  column-gap: var(--space-xl);
  align-items: start;
}
.case-study__body ul {
  padding-left: 1.2em;
}
.case-study__body li {
  margin-bottom: var(--space-m);
}
.case-study__rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}
.card-image--rail {
  max-width: 372px;
}
.card-image--rail img {
  height: auto;
}
@media (max-width: 900px) {
  .case-study {
    grid-template-columns: 1fr;
    row-gap: var(--space-l);
  }
}

/* ---------- Post list (Writing page) ---------- */
.post-list {
  list-style: none;
  margin: var(--space-l) 0 0;
  padding: 0;
  max-width: 756px;
}
.post-list__item {
  margin-bottom: var(--space-l);
}
.post-list__date {
  margin: 0 0 var(--space-xxs);
  font: var(--type-h6);
  text-transform: uppercase;
  font-feature-settings:
    "lnum" 1,
    "pnum" 1;
  color: var(--color-text);
}
.post-list__title {
  margin: 0 0 var(--space-xs);
  font: var(--type-h4);
}
.post-list__title a {
  color: var(--color-link);
  text-decoration: none;
}
.post-list__title a:hover {
  text-decoration: underline;
}
.post-list__description {
  margin: 0;
  max-width: 660px;
}
.post-list__archives {
  margin-top: var(--space-l);
}
.post-list__archives a {
  color: var(--color-link);
  text-decoration: none;
}
.post-list__archives a:hover {
  text-decoration: underline;
}

/* ---------- Contact list ---------- */
.contact-list {
  list-style: none;
  margin: var(--space-m) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}
.contact-list li {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}
.contact-list__icon {
  display: block;
  color: var(--color-link);
}
.contact-list__icon svg {
  width: 16px;
  height: 16px;
  display: block;
}
.contact-list a {
  color: var(--color-link);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--space-xxl);
  padding-block: var(--space-m) var(--space-l);
  border-top: 0.5px solid
    color-mix(in srgb, var(--color-accent) 60%, transparent);
  font: var(--type-caption);
  font-feature-settings:
    "lnum" 1,
    "pnum" 1;
  color: var(--color-text);
}
.site-footer__columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-l);
}
.site-footer p {
  margin: 0 0 var(--space-xs);
}
.site-footer i {
  font-style: italic;
}
.site-footer a {
  color: var(--color-link);
}
.site-footer__wordmark {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.site-footer__nav {
  display: flex;
  flex-direction: column;
  row-gap: var(--space-s);
}

.site-footer__nav nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-m);
}
.site-footer__nav nav a {
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.site-footer__nav nav a:hover {
  text-decoration: underline;
}
.site-footer__social {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-s);
}
.site-footer__social a {
  display: block;
  color: var(--color-link);
}
.site-footer__social svg {
  width: 16px;
  height: 16px;
  display: block;
}
.site-footer__credits .font-serif {
  font-family: var(--font-serif);
}
.site-footer__credits .font-display {
  font-family: var(--font-display);
}

@media (max-width: 768px) {
  .site-footer__columns {
    grid-template-columns: 1fr;
    gap: var(--space-m);
  }
  .site-footer__nav,
  .site-footer__credits {
    border-top: 0.5px solid
      color-mix(in srgb, var(--color-accent) 60%, transparent);
    padding-top: var(--space-m);
  }
}
