/* Fold: the page is one open bifolium. Paper leaf left, OLED leaf right, one blue crease. */

:root {
  --paper-bg: #FCFBF8;
  --paper-ink: #201E1B;
  --paper-secondary: #68625A;
  --paper-link: #175C9E;
  --oled-bg: #000000;
  --oled-ink: #F5F5F7;
  --oled-secondary: #B8B8C0;
  --oled-link: #63B3FF;
  --crease: #63B3FF;
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
  --leaf-pad: clamp(24px, 4vw, 64px);
  --gap: 72px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  color: var(--paper-ink);
  background: linear-gradient(to right, var(--paper-bg) 50%, var(--oled-bg) 50%);
  overflow-x: hidden;
}

/* The crease: one 3px line down the whole viewport, with faint fold shading either side. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 50%;
  width: 99px;
  height: 100%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(
      to right,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0.06) 48px,
      var(--crease) 48px,
      var(--crease) 51px,
      rgba(255, 255, 255, 0.05) 51px,
      rgba(255, 255, 255, 0) 99px
    );
}

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

a {
  color: var(--paper-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color 120ms;
}

.oled a {
  color: var(--oled-link);
}

a:focus-visible,
.skip:focus-visible {
  outline: 2px solid var(--paper-link);
  outline-offset: 2px;
}

.oled a:focus-visible {
  outline-color: var(--oled-link);
}

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 3;
  padding: 8px 12px;
  background: var(--paper-bg);
  color: var(--paper-link);
  font-family: var(--sans);
  font-size: 15px;
}

.skip:focus {
  top: 16px;
}

/* Rows and leaves. Each row is a symmetric two-column grid, so its columns meet at the crease. */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.leaf {
  padding-left: var(--leaf-pad);
  padding-right: var(--leaf-pad);
  min-width: 0;
}

.leaf.paper {
  color: var(--paper-ink);
}

.leaf.oled {
  color: var(--oled-ink);
}

.span {
  grid-column: 1 / -1;
}

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

.secondary {
  color: var(--paper-secondary);
}

.oled .secondary {
  color: var(--oled-secondary);
}

.small {
  font-size: 13px;
  line-height: 1.5;
  color: var(--paper-secondary);
}

.oled .small {
  color: var(--oled-secondary);
}

/* Header */
.header {
  align-items: center;
  padding-top: 28px;
  padding-bottom: 28px;
}

.header p {
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  color: var(--paper-ink);
}

.brand img {
  width: 28px;
  height: 28px;
}

.status {
  text-align: right;
  font-size: 14px;
  line-height: 1.4;
  color: var(--oled-secondary);
}

/* Display type */
h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(48px, 7.2vw, 108px);
  text-align: center;
  max-width: 14ch;
  justify-self: center;
  /* Keep serif descenders inside the split-color background's paint area. */
  padding: 40px 0 0.15em;
}

/* Ink that changes colour exactly at the crease. */
.crossing {
  background: linear-gradient(to right, var(--paper-ink) 50%, var(--oled-ink) 50%);
  /* counterform-allow: CF001 -- Ink follows the selected Paper/OLED fold; see DESIGN.md. */
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: 100%;
  max-width: none;
}

h2 {
  font-size: 40px;
  margin-bottom: 20px;
}

.text p {
  max-width: 60ch;
  margin: 0 0 1em;
}

.text p:last-child {
  margin-bottom: 0;
}

/* Hero: two phones rising out of the bottom edge, mirrored across the crease. */
.hero {
  overflow: hidden;
  grid-template-rows: auto auto 1fr;
}

.title-block {
  grid-row: 1;
}

.lede {
  grid-column: 1;
  grid-row: 2;
  font-size: 19px;
  line-height: 1.5;
  max-width: calc(34ch + 2 * var(--leaf-pad));
  margin: 28px 0 40px;
}

.hero-leaf {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero-leaf.paper {
  grid-column: 1;
  grid-row: 3;
}

.hero-leaf.oled {
  grid-column: 2;
  grid-row: 2 / 4;
}

.phone {
  width: 100%;
  max-width: 268px;
  margin: 0 auto;
}

.hero-phone {
  max-width: 340px;
  margin: 0;
}

.hero-leaf.paper .hero-phone {
  margin-left: auto;
}

.hero-leaf.oled .hero-phone {
  margin-right: auto;
}

.hero-phone figcaption {
  font-size: 13px;
  line-height: 1.4;
  color: var(--paper-secondary);
  margin-bottom: 10px;
}

.hero-leaf.paper .hero-phone figcaption {
  text-align: right;
}

.hero-leaf.oled .hero-phone figcaption {
  text-align: left;
  color: var(--oled-secondary);
}

/* Bottom 18% of each hero phone is clipped by the section's edge.
   18% of the phone's height is 37.12% of its width (2054 / 996 * 0.18). */
.hero-phone img {
  width: 100%;
  margin-bottom: -37.12%;
}

/* Feature rows */
.text {
  align-self: center;
  padding-top: 24px;
  padding-bottom: 24px;
}

/* Rows where both leaves carry text: top-align so headings share a baseline. */
.pair .text {
  align-self: start;
}

/* Wide screenshots bridge the two leaves without hiding either platform. */
.plate {
  row-gap: 40px;
}

.plate h2 {
  text-align: center;
  margin-bottom: 0;
}

.wide-shot {
  grid-column: 1 / -1;
  margin: 0;
}

.wide-shot img {
  display: block;
  margin: 0 auto;
  width: calc(100% - 2 * var(--leaf-pad));
  max-width: 1100px;
}

.ipad-shot img {
  max-width: 980px;
}

.rendering h2 + p + h2 {
  margin-top: 32px;
}

.appearance-note h2 {
  font-size: 30px;
  line-height: 1.15;
  max-width: 22ch;
  margin-bottom: 0;
}

.sources .text {
  align-self: start;
  padding-top: 0;
  padding-bottom: 0;
}

/* Access */
.prices {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 24px;
  row-gap: 6px;
  margin: 0 0 20px;
  max-width: 34ch;
  font-size: 17px;
}

.prices dt,
.prices dd {
  margin: 0;
}

.prices dd {
  text-align: right;
}

/* Footer */
.footer {
  margin-top: var(--gap);
  padding-top: 40px;
  padding-bottom: 40px;
  font-size: 15px;
}

.footer p {
  margin: 0;
}

.brand-name {
  font-family: var(--serif);
  font-size: 17px;
  margin-right: 8px;
}

.legal {
  text-align: right;
}

.legal a + a {
  margin-left: 20px;
}

/* Mobile. The header, headline, and hero phones keep the vertical fold, so the idea
   survives on a phone. Below that the fold turns horizontal: each section is one block,
   alternating Paper and OLED, text first, with the phone rising out of the block's bottom
   edge and the crease drawn as the line between blocks. */
@media (max-width: 800px) {
  :root {
    --leaf-pad: 20px;
  }

  body {
    background: var(--paper-bg);
  }

  body::before {
    display: none;
  }

  main > .row + .row {
    margin-top: 0;
  }

  /* Header: still two leaves, seam drawn as a border on the OLED side. */
  .row.header {
    grid-template-columns: 1fr 1fr;
    padding: 0;
    align-items: stretch;
  }

  .header .leaf {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .header .leaf.paper {
    background: var(--paper-bg);
  }

  .header .leaf.oled {
    background: var(--oled-bg);
    border-left: 3px solid var(--crease);
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .brand {
    font-size: 20px;
  }

  .brand img {
    width: 24px;
    height: 24px;
  }

  .status {
    font-size: 12px;
    line-height: 1.35;
    max-width: 12em;
  }

  /* Headline: one block with the split painted behind it, crease included. */
  .title-block {
    background: linear-gradient(
      to right,
      var(--paper-bg) 50%,
      var(--crease) 50%,
      var(--crease) calc(50% + 3px),
      var(--oled-bg) calc(50% + 3px)
    );
  }

  h1 {
    font-size: clamp(38px, 10.5vw, 56px);
    padding: 28px 12px 22px;
  }

  h1.crossing {
    background-image: linear-gradient(to right, var(--paper-ink) 50%, var(--oled-ink) 50%);
    /* counterform-allow: CF001 -- Preserve the same fold on phones. */
    -webkit-background-clip: text;
    background-clip: text;
  }

  /* Two phones side by side, one per leaf, clipped at the section's edge. */
  .row.hero {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .hero .title-block {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .hero-leaf {
    overflow: hidden;
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero-leaf.paper {
    grid-column: 1;
    grid-row: 2;
    background: var(--paper-bg);
    /* Match the OLED leaf's 3px crease border so both phones get the same width. */
    padding-right: 15px;
  }

  .hero-leaf.oled {
    grid-column: 2;
    grid-row: 2;
    background: var(--oled-bg);
    border-left: 3px solid var(--crease);
  }

  .hero-phone,
  .hero-leaf.paper .hero-phone,
  .hero-leaf.oled .hero-phone {
    max-width: 176px;
    margin: 0 auto;
  }

  .hero-phone figcaption {
    font-size: 12px;
    margin: 18px 0 8px;
  }

  .hero-leaf.paper .hero-phone figcaption {
    text-align: right;
    padding-right: 6px;
  }

  .hero-leaf.oled .hero-phone figcaption {
    text-align: left;
    padding-left: 6px;
  }

  .hero-phone img {
    margin-bottom: -37.12%;
  }

  /* The lede follows the phones as the first full-width Paper block. */
  .lede {
    grid-column: 1 / -1;
    grid-row: 3;
    background: var(--paper-bg);
    margin: 0;
    padding: 32px var(--leaf-pad) 8px;
    font-size: 18px;
    max-width: none;
  }

  /* Sections as single alternating blocks. */
  .row {
    grid-template-columns: 1fr;
    border-top: 3px solid var(--crease);
  }

  .header,
  .hero {
    border-top: 0;
  }

  .m-paper {
    --bg: var(--paper-bg);
    --ink: var(--paper-ink);
    --muted: var(--paper-secondary);
    --link: var(--paper-link);
  }

  .m-oled {
    --bg: var(--oled-bg);
    --ink: var(--oled-ink);
    --muted: var(--oled-secondary);
    --link: var(--oled-link);
  }

  .m-paper,
  .m-oled {
    background: var(--bg);
    color: var(--ink);
  }

  .m-paper .leaf,
  .m-oled .leaf {
    background: var(--bg);
    color: var(--ink);
  }

  .m-paper .secondary,
  .m-oled .secondary,
  .m-paper .small,
  .m-oled .small {
    color: var(--muted);
  }

  .m-paper a,
  .m-oled a {
    color: var(--link);
  }

  .text {
    order: -1;
    align-self: start;
    padding-top: 40px;
    padding-bottom: 8px;
  }

  h2 {
    font-size: 30px;
    margin-bottom: 14px;
  }

  .figure-leaf {
    overflow: hidden;
    padding-top: 20px;
    padding-bottom: 0;
  }

  .phone {
    max-width: 236px;
  }

  /* Bottom 24% of a section phone is clipped: 24% of height is 49.5% of width. */
  .figure-leaf .phone img {
    margin-bottom: -49.5%;
  }

  /* The wide figures keep their whole window or device at phone widths. */
  .plate {
    row-gap: 0;
    padding: 40px 0 36px;
  }

  .plate h2.crossing {
    background: none;
    color: var(--ink);
    padding: 0 var(--leaf-pad);
    margin-bottom: 22px;
    text-align: left;
  }

  .plate > .text {
    order: 0;
    padding-top: 0;
    padding-bottom: 20px;
  }

  .rendering {
    padding-bottom: 32px;
  }

  /* Keep every node of the Mermaid diagram visible on phones. */
  .rendering .figure-leaf .phone img {
    margin-bottom: 0;
  }

  .appearance-note .text + .text {
    padding-top: 8px;
    padding-bottom: 0;
  }

  .appearance-note h2 {
    font-size: 26px;
    max-width: 24ch;
    margin-bottom: 8px;
  }

  .ipad-section {
    border-top: 0;
  }

  /* Access: one OLED block, trial then price. */
  .access .leaf {
    padding-top: 36px;
    padding-bottom: 8px;
  }

  .access .leaf.oled {
    padding-top: 8px;
    padding-bottom: 40px;
  }

  .access .text {
    order: 0;
  }

  .prices {
    max-width: none;
  }

  /* Footer: one Paper block. */
  .footer {
    margin-top: 0;
    padding: 0;
    font-size: 14px;
  }

  .footer .leaf {
    padding-top: 28px;
    padding-bottom: 0;
  }

  .footer .leaf.oled {
    padding-top: 10px;
    padding-bottom: 40px;
  }

  .legal {
    text-align: left;
  }
}

/* Tablet: same block layout, larger devices to fill the wider blocks. */
@media (min-width: 560px) and (max-width: 800px) {
  :root {
    --leaf-pad: 32px;
  }

  .hero-phone,
  .hero-leaf.paper .hero-phone,
  .hero-leaf.oled .hero-phone {
    max-width: 250px;
  }

  h1 {
    font-size: clamp(48px, 7.4vw, 60px);
    padding-top: 36px;
    padding-bottom: 30px;
  }

  .phone {
    max-width: 300px;
  }

  .lede {
    font-size: 19px;
    padding-top: 36px;
  }

  h2 {
    font-size: 34px;
  }

  .text {
    padding-top: 48px;
  }

  .plate {
    padding: 48px 0 44px;
  }
}

@media (max-width: 360px) {
  .hero-phone,
  .hero-leaf.paper .hero-phone,
  .hero-leaf.oled .hero-phone {
    max-width: 150px;
  }

  h1 {
    font-size: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  a {
    transition: none;
  }
}
