/* Page sections, in page order */

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--white);
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration) var(--ease);
}

.site-header[data-scrolled] {
  border-bottom-color: var(--line);
}

/* Equal outer columns keep the nav centred on the full screen width */
.site-header__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-5);
  height: 76px;
}

.site-header__inner .brand {
  justify-self: start;
}

.site-nav {
  display: flex;
  gap: var(--space-6);
}

.site-nav a {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  text-underline-offset: 6px;
}

.site-nav a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.site-header__actions {
  display: flex;
  grid-column: 3;
  align-items: center;
  justify-self: end;
  gap: var(--space-3);
}

.site-header__menu {
  display: none;
}

/* Hero */
/* The hero fills the screen below the header; the phone takes whatever height is left */
.hero {
  display: flex;
  flex-direction: column;
  height: calc(100svh - 76px);
  min-height: 640px;
  padding-top: var(--space-6);
  overflow: hidden;
}

.hero__copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero__title {
  font-size: clamp(2.75rem, 6vw, 5.5rem);
  letter-spacing: var(--tracking-display);
  line-height: 0.88;
}

.hero__eyebrow {
  margin-bottom: var(--space-4);
}

.hero__lede {
  max-width: 620px;
  text-wrap: balance;
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-lg);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.hero__note {
  margin-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.hero-stage {
  position: relative;
  flex: 1;
  width: min(var(--container), 100% - var(--gutter) * 2);
  min-height: 380px;
  margin: var(--space-5) auto 0;
  /* No clipping here: shadows of the phone and cards must fade out, not stop at an edge */
}

.hero-stage__incoming {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.hero-stage__incoming .x-post {
  position: absolute;
  width: var(--card-w, 300px);
  transform-origin: top left;
}

/* Floating cards are narrower than the X column, so the action bar drops bookmark */
.hero-stage__incoming .x-post__actions span {
  gap: 3px;
}

.hero-stage__incoming .x-post__actions img {
  width: 16px;
  height: 16px;
}

.hero-stage__incoming .x-post__end img:first-child {
  display: none;
}

/* Height comes from the stage; width follows the frame's aspect ratio.
   js/hero.js sets --device-scale so the app UI scales with it. */
.hero-stage__device {
  position: absolute;
  top: var(--space-4);
  bottom: var(--space-7);
  width: auto;
  left: 50%;
  z-index: 2;
  translate: -50% 0;
}

/* "Coming next" pill under the statement sentence */
.works-with {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* One pill: "Coming next" and the platform icons */
.works-with__next {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--black-06);
  color: var(--text-muted);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}

.works-with img {
  width: 18px;
  height: 18px;
}

/* Generic section */
.section {
  padding-block: var(--section-space);
}

/* Two light sections in a row share one 1.5x gap instead of stacking two full paddings */
.section:not(.section--dark) + .section:not(.section--dark) {
  padding-top: calc(var(--section-space) * 0.5);
}

.section--dark {
  background: var(--black);
  color: var(--white);
}

/* Two dark sections in a row: one shared gap, split by a faint rule */
.section--dark + .section--dark {
  padding-top: calc(var(--section-space) * 0.5);
}

/* The rule is drawn as a 1px background line so it spans the content width, not the gutters */
.section--dark + .section--dark > .container {
  padding-top: calc(var(--section-space) * 0.5);
  background: linear-gradient(var(--white-12), var(--white-12)) center top / calc(100% - var(--gutter) * 2) 1px no-repeat;
}

.section--dark .section-lede {
  color: var(--gray);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--head-space);
}

/* Title pinned to the left edge, text to the right edge, sharing a bottom line */
.section-head--split {
  align-items: flex-end;
  justify-content: space-between;
}

.section-head--stacked {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--space-5);
}

.section-title {
  max-width: 14ch;
  font-size: var(--text-section);
}

/* Headings sized to fit on a single line on desktop (they wrap on phones) */
.section-title--one-line {
  max-width: none;
  font-size: clamp(1.75rem, 5.2vw, 4.275rem);
}

.section-lede {
  max-width: 460px;
  color: var(--text-muted);
  font-size: var(--text-lg);
}

.section-lede a {
  font-weight: var(--weight-semibold);
  text-underline-offset: 4px;
}

/* Full photo with a caption pill, in its own section after the three steps */
.photo-banner {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

/* 30% shorter than the photo's natural height (≈1.55:1 → 20:9), framed on the person in the centre */
.photo-banner img {
  width: 100%;
  aspect-ratio: 20 / 9;
  object-fit: cover;
  object-position: 50% 40%;
}

.photo-banner figcaption {
  position: absolute;
  bottom: var(--space-5);
  left: var(--space-5);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--white);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

/* Columns divided by hairlines, like a spec sheet */
.step {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-6);
  border-left: 1.5px solid var(--black);
}

.step__number {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
}

.step__art {
  width: 120px;
  height: 100px;
  margin-block: var(--space-6) var(--space-7);
}

.step h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

.step p {
  max-width: 28ch;
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Demo: starts with Tiho off, then filters itself as you scroll */
.demo__inner {
  display: grid;
  grid-template-columns: 5fr 7fr;
  align-items: center;
  gap: var(--space-8);
}

.demo__copy .section-title {
  font-size: clamp(2.5rem, 4.6vw, 4.25rem);
}

.demo__copy .section-lede {
  margin-top: var(--space-5);
}

.demo__copy .segmented {
  margin-top: var(--space-6);
}

/* Counters sit with the switch that drives them; the number leads, smaller than the heading */
.demo__stats {
  display: flex;
  gap: var(--space-7);
  margin-top: var(--space-6);
}

.demo__stats > div {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
}

.demo__stats dt {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.demo__stats dd {
  font-size: clamp(2.25rem, 3.4vw, 3rem);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-display);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.demo__stats dd.is-bumped {
  animation: bump 420ms var(--ease);
}

@keyframes bump {
  40% {
    scale: 1.18;
  }
}

.demo .browser {
  border: 1.5px solid var(--black);
}

/* A wide image crop, so the whole feed fits on one screen while pinned */
.demo .x-post__media {
  aspect-ratio: auto;
  height: 120px;
}

/* A tall photo cropped to its top, where the book titles are */
.x-post__media--top {
  object-position: center 18%;
}

/* Desktop: the demo pins for a long stretch of scrolling; js/demo.js maps that
   stretch to the sequence, so the page only moves on once it has finished.
   The browser window is scaled (zoom) by js/demo.js to fit the screen height. */
@media (min-width: 901px) {
  .demo {
    min-height: 280svh;
  }

  .demo__inner {
    position: sticky;
    top: 76px;
    height: calc(100svh - 76px);
  }
}

/* Closer */
.closer__inner {
  display: grid;
  grid-template-columns: 1fr 400px;
  align-items: center;
  gap: var(--space-8);
}

.closer__title {
  max-width: 11ch;
  font-size: clamp(3.5rem, 7vw, 6.5rem);
  letter-spacing: var(--tracking-display);
  line-height: 0.9;
}

.closer__copy .section-lede {
  margin-block: var(--space-5) var(--space-6);
}

.popup {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--white);
  color: var(--black);
}

.popup__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.popup__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  padding: 18px;
}

.popup__stats div {
  display: grid;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--black-06);
}

.popup__stats strong {
  font-size: 1.625rem;
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.popup__stats span {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.popup__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 6px 18px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.popup__segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--black-06);
}

.popup__segmented button {
  padding: 5px 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.popup__segmented button:hover {
  color: var(--black);
}

.popup__segmented button[aria-pressed="true"] {
  background: var(--black);
  color: var(--white);
}

/* The popup is white inside a dark section, so its focus rings stay black */
.popup :focus-visible {
  outline-color: var(--black);
  outline-offset: 2px;
}

/* One line under the controls that says what the current setting does */
.popup__note {
  min-height: 2.9em;
  padding: 4px 18px 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.popup__title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: 14px 18px 8px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.popup__title span {
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  text-transform: none;
}

/* Rows fold open and shut as sensitivity changes, like hidden posts on X */
.popup__list li {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 320ms var(--ease), opacity 260ms var(--ease);
}

.popup__list li[hidden] {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
}

.popup__list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 0;
  overflow: hidden;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease);
}

.popup__list li[hidden] button {
  padding-block: 0;
}

.popup__list button:hover {
  background: var(--black-03);
}

.popup__list button:focus-visible {
  outline-offset: -3px;
}

.popup__list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--duration) var(--ease);
}

.popup__list em {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 3px 9px;
  border: 1.5px solid var(--black);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-style: normal;
  font-weight: var(--weight-semibold);
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

/* Voted to keep: the tag fills, the post text steps back */
.popup__list button[aria-pressed="true"] span {
  color: var(--text-muted);
}

.popup__list button[aria-pressed="true"] em {
  background: var(--black);
  color: var(--white);
}

.popup__list button[aria-pressed="true"] em::before {
  content: "";
  width: 11px;
  height: 11px;
  background: url("../assets/icons/check-white.svg") center / contain no-repeat;
}

/* After a few votes, the popup says what they did */
.popup__learned {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 360ms var(--ease), opacity 360ms var(--ease);
}

.popup__learned > p {
  min-height: 0;
  overflow: hidden;
  padding-inline: 18px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.popup__learned.is-shown {
  grid-template-rows: 1fr;
  opacity: 1;
}

.popup__learned.is-shown > p {
  padding-block: 12px 14px;
  border-top: 1px solid var(--line);
}

/* Paused: everything below the header steps back until the switch is on again */
.popup__body {
  transition: opacity 300ms var(--ease);
}

.popup.is-off .popup__body {
  opacity: 0.32;
}

.popup__paused {
  margin-left: auto;
  margin-right: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

/* Statement: loud by default, quiet once the switch is on */
/* Extra breathing room so the sentence reads as its own moment */
/* A little more air above, so the sentence reads as its own moment after the hero */
.statement {
  padding-top: calc(var(--section-space) * 2.25);
  padding-bottom: calc(var(--section-space) * 2);
}

.statement__text {
  max-width: 22ch;
  font-size: clamp(2rem, 5.2vw, 4.5rem);
  font-weight: var(--weight-bold);
  letter-spacing: -0.035em;
  line-height: 1.18;
}

.statement__soft,
.statement__noise {
  transition: color 600ms var(--ease);
}

.statement__noise {
  text-decoration: line-through;
  text-decoration-color: transparent;
  text-decoration-thickness: 0.08em;
  transition: color 600ms var(--ease), text-decoration-color 600ms var(--ease) 200ms;
}

.statement.is-quiet .statement__soft,
.statement.is-quiet .statement__noise {
  color: var(--gray);
}

.statement.is-quiet .statement__noise {
  text-decoration-color: var(--gray);
}

/* Overlapping app tiles, sized in em so they track the text */
.app-stack {
  display: inline-flex;
  vertical-align: -0.12em;
  margin-inline: 0.1em;
}

.app-tile {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.05em;
  height: 1.05em;
  margin-left: -0.14em;
  border-radius: 0.26em;
  background: var(--white);
  box-shadow: 0 0.08em 0.2em rgba(26, 25, 27, 0.18);
  transition: rotate 500ms var(--ease);
}

/* Slightly hand-placed, never perfectly lined up */
.app-tile:nth-child(1) {
  margin-left: 0;
  rotate: -2deg;
}

.app-tile:nth-child(2) {
  rotate: 1deg;
  translate: 0 0.03em;
}

.app-tile:nth-child(3) {
  rotate: -1deg;
}

.app-tile img {
  width: 0.6em;
  height: 0.6em;
}

/* Inline black-and-white switch */
.big-switch {
  position: relative;
  display: inline-block;
  width: 1.9em;
  height: 1em;
  margin-inline: 0.08em;
  padding: 0;
  border: 0.06em solid var(--black);
  border-radius: var(--radius-pill);
  background: var(--white);
  font-size: 0.88em; /* 12% smaller than the text; all sizes below are in em */
  vertical-align: -0.06em;
  cursor: pointer;
  transition: background-color 400ms var(--ease);
}

.big-switch__knob {
  position: absolute;
  top: 50%;
  left: 0.1em;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--black);
  translate: 0 -50%;
  box-shadow: 0 0.04em 0.12em rgba(26, 25, 27, 0.3);
  transition: left 450ms cubic-bezier(0.5, 1.5, 0.5, 1), background-color 400ms var(--ease);
}

.big-switch[aria-checked="true"] {
  background: var(--black);
}

.big-switch[aria-checked="true"] .big-switch__knob {
  left: calc(100% - 0.8em);
  background: var(--white);
}

.big-switch:focus-visible {
  outline-offset: 0.08em;
}


/* The hero phone's X chrome: profile photo, "For you" menu, Grok and Chat tabs, the Ad label */
.app__bar {
  position: relative;
}

.app__me {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  translate: 0 -50%;
}

.app__chevron {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  vertical-align: -1px;
}

.app__badged {
  position: relative;
  display: inline-flex;
}

.app__badged i {
  position: absolute;
  top: -5px;
  right: -9px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid var(--white);
  border-radius: var(--radius-pill);
  background: #1D9BF0;
  color: var(--white);
  font-size: 10px;
  font-style: normal;
  font-weight: var(--weight-bold);
  line-height: 14px;
  text-align: center;
}

.x-post__head .x-post__ad {
  flex: none;
  margin-left: auto;
}

.x-post__ad + .x-post__more {
  margin-left: 6px;
}
