/* ------------------------------------------------------------------
   Hoang Minh Duc — independent iOS developer
   Black-and-white system. The only colour on the page is app artwork.
   Display: Bricolage Grotesque · Body: Newsreader · Data: Martian Mono
------------------------------------------------------------------- */

/* 1. Tokens ------------------------------------------------------- */

:root {
  --paper: #ffffff;
  --ink: #0b0b0c;
  --graphite: #56565c;
  --hairline: #e5e5e7;
  --wash: #f6f6f5;
  --ink-soft: rgba(11, 11, 12, 0.06);

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Newsreader", ui-serif, Georgia, serif;
  --data: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(20px, 5vw, 56px);
  --measure: 66ch;
  --band: clamp(72px, 10vw, 148px);
  --ease: cubic-bezier(0.22, 0.68, 0.24, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0b0c;
    --ink: #fafaf9;
    --graphite: #9a9aa1;
    --hairline: #232326;
    --wash: #141416;
    --ink-soft: rgba(250, 250, 249, 0.08);
  }
}

:root[data-theme="dark"] {
  --paper: #0b0b0c;
  --ink: #fafaf9;
  --graphite: #9a9aa1;
  --hairline: #232326;
  --wash: #141416;
  --ink-soft: rgba(250, 250, 249, 0.08);
}

/* 2. Base --------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

img { max-width: 100%; display: block; }

a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 700;
  font-variation-settings: "wdth" 96;
  letter-spacing: -0.028em;
  line-height: 0.98;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--ink); color: var(--paper); }

.wrap {
  width: 100%;
  max-width: 1220px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  z-index: 100;
  font-family: var(--data);
  font-size: 0.75rem;
}
.skip:focus { left: 8px; top: 8px; }

/* 3. Shared type roles -------------------------------------------- */

.label {
  font-family: var(--data);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0;
}

.lede {
  font-size: clamp(1.14rem, 1.5vw, 1.34rem);
  line-height: 1.52;
  color: var(--graphite);
  max-width: 46ch;
}

.rule {
  height: 1px;
  background: var(--hairline);
  border: 0;
  margin: 0;
}

/* 4. Masthead ----------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.masthead[data-stuck="true"] { border-bottom-color: var(--hairline); }

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 68px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font-family: var(--data);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wordmark__mark {
  width: 26px;
  height: 26px;
  flex: none;
  background: var(--ink);
  clip-path: url(#squircle);
  display: grid;
  place-items: center;
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  padding-bottom: 1px;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.2vw, 30px);
}

.nav__link {
  font-family: var(--data);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--graphite);
  transition: color 0.2s var(--ease);
}
.nav__link:hover { color: var(--ink); }

@media (max-width: 640px) {
  .nav__link[data-optional] { display: none; }
}

.invert {
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.invert:hover { border-color: var(--ink); transform: rotate(180deg); }
.invert svg { width: 15px; height: 15px; }

/* 5. Buttons ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--data);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.btn:hover { transform: translateY(-2px); opacity: 0.88; }
.btn svg { width: 13px; height: 13px; }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--hairline);
}
.btn--ghost:hover { border-color: var(--ink); }

/* 6. Hero --------------------------------------------------------- */

.hero {
  padding-top: clamp(48px, 8vw, 96px);
  padding-bottom: clamp(56px, 8vw, 110px);
}

.hero__grid {
  display: grid;
  gap: clamp(48px, 7vw, 76px);
  align-items: center;
}

@media (min-width: 940px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: clamp(48px, 6vw, 88px);
  }
}

.hero__eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(24px, 3vw, 34px);
}
.hero__eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--ink);
  flex: none;
}

.hero h1 {
  font-size: clamp(2.65rem, 6.6vw, 5.4rem);
  font-variation-settings: "wdth" 88;
  line-height: 0.93;
  letter-spacing: -0.038em;
  margin-bottom: clamp(22px, 3vw, 32px);
}

.hero h1 em {
  font-style: normal;
  font-family: var(--body);
  font-weight: 300;
  font-style: italic;
  letter-spacing: -0.015em;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(28px, 3.4vw, 40px);
}

/* Stat strip */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: clamp(40px, 5vw, 60px);
  background: var(--hairline);
  border-block: 1px solid var(--hairline);
}
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stat {
  background: var(--paper);
  padding: 18px 4px 18px 0;
  display: flex;
  flex-direction: column-reverse; /* number reads first, caption underneath */
  align-items: flex-start;
}
.stat__num {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 700;
  font-variation-settings: "wdth" 92;
  letter-spacing: -0.03em;
  line-height: 1;
  display: block;
}
.stat__cap {
  font-family: var(--data);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--graphite);
  display: block;
  margin-top: 9px;
}

/* 7. Signature: the icon construction grid ------------------------ */

.plate {
  position: relative;
  width: min(100%, 460px);
  margin-inline: auto;
  aspect-ratio: 1;
}

.plate__svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* Load sequence: the guides draw first, the icon settles into them after. */
.plate__art { opacity: 0; transition: opacity 0.7s var(--ease) 1.15s; }
.plate.is-ready .plate__art { opacity: 1; }

.plate__guides { color: var(--ink); }
.plate__guides .g-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

/* Guides sit quiet over the artwork until you ask for them. */
.plate__guides--over { opacity: 0.5; transition: opacity 0.8s var(--ease) 1.35s; }
.plate.is-ready .plate__guides--over { opacity: 0.14; }
.plate.is-guided .plate__guides--over {
  opacity: 0.92;
  color: #fff;
  mix-blend-mode: difference;
  transition-delay: 0s;
}

.plate__ticks { color: var(--graphite); }
.plate__ticks .g-line { fill: none; stroke: currentColor; stroke-width: 1; vector-effect: non-scaling-stroke; }
.plate__ticks text {
  font-family: var(--data);
  font-size: 26px;
  letter-spacing: 2px;
  fill: currentColor;
}

.plate__caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  color: var(--graphite);
  font-family: var(--data);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.2s var(--ease);
}
.toggle:hover { color: var(--ink); }
.toggle__box {
  width: 13px;
  height: 13px;
  border: 1px solid currentColor;
  position: relative;
}
.toggle[aria-pressed="true"] { color: var(--ink); }
.toggle[aria-pressed="true"] .toggle__box::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--ink);
}

/* Draw-on animation */
@media (prefers-reduced-motion: no-preference) {
  .plate .g-line {
    stroke-dasharray: var(--len, 3000);
    stroke-dashoffset: var(--len, 3000);
  }
  .plate.is-ready .g-line {
    animation: draw 1.1s var(--ease) forwards;
    animation-delay: calc(var(--i, 0) * 55ms);
  }
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* 8. Bands & section heads ---------------------------------------- */

.band {
  padding-block: var(--band);
  border-top: 1px solid var(--hairline);
}

.band--wash { background: var(--wash); }

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: clamp(40px, 5vw, 64px);
}

.head h2 {
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  font-variation-settings: "wdth" 90;
}

/* 9. App entries -------------------------------------------------- */

.apps { display: grid; gap: clamp(64px, 9vw, 120px); }

.app { display: grid; gap: clamp(28px, 4vw, 48px); }

@media (min-width: 900px) {
  .app {
    grid-template-columns: 268px minmax(0, 1fr);
    gap: clamp(40px, 5vw, 72px);
  }
  .app__rail { position: sticky; top: 100px; align-self: start; }
}

.icon {
  position: relative;
  width: clamp(96px, 22vw, 132px);
  aspect-ratio: 1;
}
.icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: url(#squircle);
}
.icon::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: url(#squircle);
  box-shadow: inset 0 0 0 1px var(--ink-soft);
  pointer-events: none;
}

.spec {
  margin: 26px 0 0;
  border-top: 1px solid var(--hairline);
  font-family: var(--data);
  font-size: 0.68rem;
}
.spec div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
}
.spec dt { color: var(--graphite); letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.6rem; }
.spec dd { margin: 0; text-align: right; }

.app__genre {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.chip {
  font-family: var(--data);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 11px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--graphite);
}

.app h3 {
  font-size: clamp(1.75rem, 3.2vw, 2.6rem);
  font-variation-settings: "wdth" 90;
  margin-bottom: 14px;
}

.app__tagline {
  font-family: var(--body);
  font-style: italic;
  font-size: clamp(1.1rem, 1.6vw, 1.3rem);
  color: var(--graphite);
  margin-bottom: 22px;
}

.app__body { max-width: 58ch; }

.features {
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
  display: grid;
  gap: 1px;
  background: var(--hairline);
  border-block: 1px solid var(--hairline);
  max-width: 58ch;
}
@media (min-width: 560px) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.features li {
  background: var(--paper);
  padding: 13px 16px 13px 0;
  font-size: 0.96rem;
  line-height: 1.4;
  display: flex;
  gap: 10px;
}
.band--wash .features li { background: var(--wash); }
.features li::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 7px;
  flex: none;
  background: var(--ink);
  clip-path: url(#squircle);
}

.app__cta { margin-top: 30px; }

/* Screenshot rail */
.shots {
  display: flex;
  gap: 14px;
  margin-top: 34px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 12px;
  scrollbar-width: thin;
}
.shots::-webkit-scrollbar { height: 3px; }
.shots::-webkit-scrollbar-thumb { background: var(--hairline); }

.shot {
  flex: none;
  width: clamp(132px, 30vw, 168px);
  scroll-snap-align: start;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
  background: var(--wash);
}
.shot img { width: 100%; height: auto; }

/* 10. Prose (about + legal) --------------------------------------- */

.prose { max-width: var(--measure); }
.prose p { font-size: 1.08rem; }
.prose a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-style: dotted; }

.about__grid { display: grid; gap: clamp(32px, 5vw, 64px); }
@media (min-width: 900px) {
  .about__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.contact-line {
  font-family: var(--display);
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  font-weight: 600;
  font-variation-settings: "wdth" 90;
  letter-spacing: -0.03em;
  text-decoration: none;
  display: inline-block;
  border-bottom: 2px solid var(--hairline);
  padding-bottom: 4px;
  transition: border-color 0.25s var(--ease);
  overflow-wrap: anywhere;
}
.contact-line:hover { border-color: var(--ink); }

/* 11. Footer ------------------------------------------------------ */

.footer {
  border-top: 1px solid var(--hairline);
  padding-block: clamp(40px, 6vw, 64px);
}
.footer__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 40px;
  justify-content: space-between;
  align-items: flex-start;
}
.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
}
.footer__links a {
  font-family: var(--data);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--graphite);
}
.footer__links a:hover { color: var(--ink); }

/* 12. Legal documents --------------------------------------------- */

.doc-head { padding-block: clamp(48px, 7vw, 92px) clamp(32px, 4vw, 48px); }
.doc-head h1 {
  font-size: clamp(2.3rem, 5.4vw, 4.2rem);
  font-variation-settings: "wdth" 88;
  margin-block: 22px 26px;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
}

.doc {
  display: grid;
  gap: clamp(36px, 5vw, 56px);
  padding-bottom: clamp(64px, 9vw, 120px);
}
@media (min-width: 960px) {
  .doc { grid-template-columns: 232px minmax(0, 1fr); gap: clamp(48px, 6vw, 88px); }
}

.toc { align-self: start; }
@media (min-width: 960px) {
  .toc { position: sticky; top: 100px; max-height: calc(100vh - 130px); overflow-y: auto; }
}
.toc ol {
  list-style: none;
  counter-reset: toc;
  margin: 18px 0 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
}
.toc li { counter-increment: toc; border-bottom: 1px solid var(--hairline); }
.toc a {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  font-family: var(--data);
  font-size: 0.65rem;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--graphite);
  transition: color 0.2s var(--ease);
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--ink);
  opacity: 0.35;
  flex: none;
}
.toc a:hover, .toc a[aria-current="true"] { color: var(--ink); }
.toc a[aria-current="true"]::before { opacity: 1; }

.clause { counter-increment: clause; margin-bottom: clamp(40px, 5vw, 60px); scroll-margin-top: 96px; }
.clause:last-child { margin-bottom: 0; }
.doc__body { counter-reset: clause; max-width: var(--measure); }

.clause h2 {
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 16px;
  display: flex;
  gap: 14px;
  align-items: baseline;
}
.clause h2::before {
  content: counter(clause, decimal-leading-zero);
  font-family: var(--data);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--graphite);
  flex: none;
}

.clause h3 {
  font-family: var(--data);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 26px 0 10px;
}

.clause ul { margin: 0 0 1.1em; padding-left: 1.15em; }
.clause li { margin-bottom: 0.45em; }
.clause li::marker { color: var(--graphite); }

.callout {
  border-left: 2px solid var(--ink);
  padding: 4px 0 4px 20px;
  margin: 24px 0;
  font-size: 1rem;
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
@media (min-width: 620px) { .doc table { display: table; white-space: normal; } }
.doc th, .doc td {
  text-align: left;
  padding: 11px 16px 11px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.doc th {
  font-family: var(--data);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--graphite);
  font-weight: 500;
}

/* 13. Scroll reveal ----------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(14px); }
  .reveal.is-in {
    opacity: 1;
    transform: none;
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
