/*
 * SSHEN — homepage styles
 * Rebuilt from the Cargo site (sshen.info). All sizes are in rem, and the
 * root font-size scales with the viewport the same way Cargo's does:
 *   375px → 9.6px · 1024px → 11.06px · 1440px → 12.96px · 1920px → 14.4px
 */

/* ABC Diatype Edu (Dinamo, educational license). License terms forbid public
 * repositories and public servers for the font files: keep this repo private. */

@font-face {
  font-family: "ABC Diatype";
  src: url("/fonts/ABCDiatypeEdu-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ABC Diatype";
  src: url("/fonts/ABCDiatypeEdu-RegularItalic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "ABC Diatype";
  src: url("/fonts/ABCDiatypeEdu-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ABC Diatype";
  src: url("/fonts/ABCDiatypeEdu-MediumItalic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "ABC Diatype";
  src: url("/fonts/ABCDiatypeEdu-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ABC Diatype";
  src: url("/fonts/ABCDiatypeEdu-BoldItalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --font: "ABC Diatype", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --ink: rgba(0, 0, 0, 0.85);
  --ink-strong: #000;
  --muted: #9c9c9c;
  --hover: #9370db;
  --bg: #fff;

  --pad: 2.5rem;  /* page padding */
  --gap: 2.5rem;  /* column gutter */
  --row-gap: 2.6rem;
}

/* Chinese copies (zh/): the Latin fonts have no Chinese glyphs, so name the
   system Chinese fonts before the generic fallback */
:root:lang(zh) {
  --font: "ABC Diatype", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

/* dark theme: set on the homepage by the toggle (see theme.js) */
:root[data-theme="dark"] {
  --ink: rgba(255, 255, 255, 0.85);
  --ink-strong: #fff;
  --muted: #8a8a8a;
  --bg: #1c1c1c;
  color-scheme: dark;
}

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

html {
  font-size: min(calc(6.38px + 0.457vw), calc(8.64px + 0.3vw));
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* always keep the scrollbar's space, so short pages (the password gate)
     don't shift the header sideways compared to long ones */
  overflow-y: scroll;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
p {
  margin: 0;
}

img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none; /* no "Save Image" long-press on iOS */
  user-select: none;
  display: block;
  max-width: 100%;
  height: auto;
  border: 0;
  margin-bottom: 0.5em;
}

a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover,
a:hover .title {
  color: var(--hover);
}

/* the image link itself shouldn't tint anything */
a.image-link:hover {
  color: inherit;
}

/* ---------- layout ---------- */

.container {
  width: 99%;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
  align-items: start;
}

.span-1  { grid-column: span 1; }
.span-2  { grid-column: span 2; }
.span-3  { grid-column: span 3; }
.span-4  { grid-column: span 4; }
.span-5  { grid-column: span 5; }
.span-6  { grid-column: span 6; }
.span-7  { grid-column: span 7; }
.span-8  { grid-column: span 8; }
.span-9  { grid-column: span 9; }
.span-10 { grid-column: span 10; }
.span-11 { grid-column: span 11; }
.span-12 { grid-column: span 12; }

/* ---------- type ---------- */

.heading {
  font-family: var(--font);
  font-size: 3rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04rem;
  color: var(--ink);
}

.small {
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink-strong);
}

.arrow {
  font-weight: 300;
  margin-left: 0.1em;
}

/* ---------- header ---------- */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--pad) var(--pad);
}

.site-header .heading a {
  color: var(--ink);
}

.site-header .heading a:hover {
  color: var(--hover);
}

/* on/off switch: the knob slides right when dark mode is on */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s ease;
}

.theme-toggle:hover {
  color: var(--hover);
}

.theme-toggle:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

.theme-toggle-track {
  position: relative;
  display: block;
  width: 2.6rem;
  height: 1.4rem;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.theme-toggle-knob {
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
  transition: transform 0.3s ease;
}

.theme-toggle[aria-checked="true"] .theme-toggle-knob {
  transform: translate(1.3rem, -50%);
}

/* the language switch sits left of the theme switch (see lang.js) */
.site-header-tools {
  display: flex;
  align-items: center;
  gap: 2.4rem;
}

.lang-toggle {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.3s ease;
}

.lang-toggle:hover {
  color: var(--hover);
}

.lang-toggle:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

/* ---------- main ---------- */

main {
  padding: var(--pad) var(--pad) 0;
}

.intro .links {
  margin-top: 1.6em;
}

.intro .links a {
  display: block;
  width: fit-content;
}

.intro a.underline {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.intro p + p {
  margin-top: 1.6em;
}

.hero-image img {
  width: 100%;
  margin-bottom: 0;
}

/* section headings — spacing mirrors the live site per section */
.section-title {
  margin-top: var(--before, 6.5rem);
  margin-bottom: var(--after, 1.8rem);
}

.row + .row {
  margin-top: var(--row-gap);
}

/* ---------- project card ---------- */

.project .title {
  display: block;
  transition: color 0.3s ease;
}

.project .desc {
  margin-top: 1.8rem;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.5;
}

.project .media {
  margin-top: 1.8rem;
}

.project .media {
  display: block;
}

.project .media img,
.project .media video {
  display: block;
  width: 100%;
  margin-bottom: 0;
}

/* stand-in for a card whose cover isn't ready yet */
.project .media-placeholder {
  aspect-ratio: 16 / 9;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
}

/* descriptions stretch so every cover in a row starts at the same height */
.selected-work .project {
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

.selected-work .desc {
  flex: 1;
}

/* selected work covers match the product design overview: 16:9, square corners */
.selected-work .media img,
.selected-work .media video {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ---------- project pages (converted Cargo content) ---------- */

/* Cargo's default page margin is 2rem; some pages override it (see <main>) */
.cargo {
  --page-pad: 2rem;
  padding: var(--page-pad);
}

/* pages with a black content area (text colours come inline from Cargo) */
.cargo.dark {
  background: #000;
}

.cargo.loose small {
  line-height: 1.8;
}

/* Cargo's grid: columns separated by the row's pad, adjacent rows by min(pad) */
.cargo .row {
  --pad: 0rem;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--pad);
  align-items: start;
  margin-top: var(--top, 0);
}

.cargo .row.auto {
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}

.cargo .col {
  min-width: 0;
}

/* images sit inline in the text flow, like Cargo */
.cargo img {
  display: inline;
  width: 100%;
  height: auto;
  vertical-align: baseline;
  margin-bottom: 0.5em;
}

/* an inline-block <small> shrink-wraps, so a 100%-wide image inside it collapses */
.cargo small:has(img) {
  display: inline;
}

.cargo small {
  display: inline-block;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink-strong);
}

.cargo h2 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
}

.cargo hr {
  height: 1px;
  border: 0;
  background: rgba(0, 0, 0, 0.5);
  margin: 0.5em 0;
}

.cargo ol,
.cargo ul {
  margin: 0;
  padding: 0 0 0 2.5em;
}

.cargo iframe {
  border: 0;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 4.2rem;
  padding: 0 2rem 3rem;
}

.site-footer a + a,
.site-footer span {
  margin-left: 2.4em;
}

/* ---------- mobile (Cargo's mobile layout) ---------- */

@media (max-width: 767px) {
  html {
    font-size: 9.6px;
  }

  :root {
    --pad: 2rem;
  }

  .container {
    width: 100%;
  }

  .grid {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--gap);
  }

  [class*="span-"] {
    grid-column: 1 / -1;
  }

  .cargo {
    padding: var(--pad);
  }

  .cargo .row.responsive {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--pad);
  }

  .cargo .row.responsive > .col {
    grid-column: 1 / -1;
  }

  .cargo .row.responsive > .col.empty {
    display: none;
  }

  /* empty spacer columns only exist to keep desktop rows aligned */
  .grid > :empty {
    display: none;
  }

  .row + .row {
    margin-top: var(--gap);
  }

  .site-footer {
    padding: 0 1.6rem 2.4rem;
  }

  .site-footer span {
    display: block;
    margin: 0.4em 0 0;
  }
}

/* product design password gate */
.password-gate {
  display: flex;
  justify-content: center;
  padding: 12rem 0 8rem;
}

.password-gate[hidden],
:root[data-unlocked] .password-gate {
  display: none;
}

.password-form {
  width: min(100%, 28rem);
}

.password-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.password-row {
  display: flex;
  gap: 0.75rem;
}

.password-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.6rem 0.8rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
}

.password-submit {
  font: inherit;
  padding: 0.6rem 1rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.password-error {
  margin-top: 0.75rem;
}

.password-error[hidden] {
  display: none;
}
