/*
  The Pretty Apps Company of iOS
  Tokens mirror the frontmatter in PRETTY-APPS-DESIGN.md. Change them there first,
  then here. Plain CSS, no build step.
*/

:root {
  /* Studio: white paper, black ink. Color belongs to the apps. */
  --paper: #ffffff;
  --ink: #111111;
  --ink-hover: #2b2b2b;
  --ink-soft: #5e5e5b;
  --ink-faint: #a3a39f;
  --line: #ebebe8;
  --line-strong: #d4d4cf;

  /* System signals, used only as 7px status dots */
  --live: #1f9d55;
  --soon: #e8a317;

  /* App worlds, used only inside that app's stage */
  --mat-ground: #0e2c25;
  --mat-line: rgb(226 216 120 / 0.13);
  --mat-line-major: rgb(226 216 120 / 0.3);
  --mat-ruler: rgb(226 216 120 / 0.7);
  --melt-ground: #db0100;
  --melt-ink: #ffffff;

  --radius-md: 16px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
  --section: clamp(72px, 10vw, 128px);

  /* Only objects (app icons) cast shadows. UI never does. */
  --shadow-object: drop-shadow(0 1px 1px rgb(17 17 17 / 0.08)) drop-shadow(0 10px 14px rgb(17 17 17 / 0.16));
  --shadow-object-lift: drop-shadow(0 2px 2px rgb(17 17 17 / 0.08)) drop-shadow(0 20px 22px rgb(17 17 17 / 0.22));

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --icon-shelf: clamp(64px, 11vw, 128px);

  --font-sans: "Geist", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
  --font-accent: "Fraunces", Georgia, serif; /* italic only: "pretty" + signature */
  --font-melt: "Young Serif", Georgia, serif; /* Melt stage only */
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-lg);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

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

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

.label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.label-soft {
  color: var(--ink-soft);
}

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand svg {
  flex-shrink: 0;
  transition: rotate 0.45s var(--ease-spring);
}

.brand:hover svg {
  rotate: -8deg;
}

.nav {
  display: flex;
  gap: var(--space-lg);
  font-size: 14px;
  color: var(--ink-soft);
}

.nav a {
  transition: color 0.2s;
}

.nav a:hover {
  color: var(--ink);
}

/* ---------- Hero ---------- */

.hero {
  padding-top: clamp(48px, 10vw, 120px);
}

.hero-title {
  margin-top: var(--space-lg);
  font-size: clamp(52px, 10.5vw, 128px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.pretty {
  position: relative;
  display: inline-block;
  padding-right: 0.04em;
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: -0.02em;
}

.pretty-underline {
  position: absolute;
  left: 0;
  bottom: -0.1em;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pretty-underline path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.1s 0.5s var(--ease-out) forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.hero-sub {
  margin-top: var(--space-xl);
  max-width: 40ch;
  font-size: clamp(18px, 1.6vw, 21px);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ---------- Shelf (one row of a home screen) ---------- */

.shelf {
  margin-top: clamp(64px, 9vw, 112px);
}

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-lg);
  padding-top: var(--space-xl);
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.icon-object {
  display: block;
  width: var(--icon-shelf);
  aspect-ratio: 1;
  filter: var(--shadow-object);
  transition:
    filter 0.3s var(--ease-out),
    scale 0.3s var(--ease-spring);
}

/* Real squircle, not border-radius. The mask is the app-icon silhouette. */
.icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-mask: url(assets/squircle.svg) center / 100% 100% no-repeat;
  mask: url(assets/squircle.svg) center / 100% 100% no-repeat;
}

.slot:hover .icon-object,
.slot:focus-visible .icon-object {
  filter: var(--shadow-object-lift);
  animation: jiggle 0.26s ease-in-out infinite;
}

.slot:active .icon-object {
  scale: 0.92;
}

/* iOS edit-mode wobble */
@keyframes jiggle {
  0%,
  100% {
    rotate: -1.5deg;
  }
  50% {
    rotate: 1.5deg;
  }
}

.slot-name {
  margin-top: var(--space-xs);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.slot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: -6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.slot-empty,
.slot-empty .slot-status {
  color: var(--ink-faint);
}

.icon-empty {
  display: grid;
  place-items: center;
  width: var(--icon-shelf);
  aspect-ratio: 1;
  border: 1.5px dashed var(--line-strong);
  border-radius: 23%;
}

.dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.dot-live {
  background: var(--live);
  box-shadow: 0 0 0 3px rgb(31 157 85 / 0.15);
}

.dot-soon {
  background: var(--soon);
  box-shadow: 0 0 0 3px rgb(232 163 23 / 0.18);
}

/* ---------- App feature ---------- */

.feature {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center;
  gap: clamp(32px, 6vw, 96px);
  padding-block: var(--section);
  border-top: 1px solid var(--line);
}

.feature:first-child {
  margin-top: var(--section);
}

.feature-flip {
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
}

.feature-flip .feature-copy {
  order: 2;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.feature-name {
  margin-top: var(--space-lg);
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.045em;
}

.feature-tagline {
  margin-top: var(--space-md);
  max-width: 24ch;
  font-size: clamp(20px, 2vw, 24px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.feature-body {
  margin-top: var(--space-md);
  max-width: 46ch;
  color: var(--ink-soft);
}

.flows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--line);
}

.flows li {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.flows strong {
  margin-top: var(--space-xs);
  font-size: 17px;
  font-weight: 500;
}

.flows li > span:last-child {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  height: 48px;
  padding-inline: 22px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 500;
  transition:
    background 0.2s,
    scale 0.25s var(--ease-spring);
}

.button:hover {
  background: var(--ink-hover);
}

.button:active {
  scale: 0.96;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line-strong);
  font-size: 15px;
  font-weight: 500;
  transition: border-color 0.2s;
}

.link:hover {
  border-color: var(--ink);
}

.arrow {
  transition: translate 0.25s var(--ease-out);
}

.arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button:hover .arrow,
.link:hover .arrow {
  translate: 2px -2px;
}

/* ---------- Stages (each app's own world) ---------- */

.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 6 / 5;
  border-radius: var(--radius-lg);
}

/* Mat: self-healing cutting mat. 16px minor grid, 80px major, origin at 40px. */
.stage-mat {
  display: grid;
  place-items: center;
  background-color: var(--mat-ground);
  background-image:
    linear-gradient(var(--mat-line-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line-major) 1px, transparent 1px),
    linear-gradient(var(--mat-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
  background-size:
    80px 80px,
    80px 80px,
    16px 16px,
    16px 16px;
  background-position: 40px 40px;
}

.mat-ruler span {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  color: var(--mat-ruler);
}

.mat-ruler-x {
  top: 18px;
  translate: -50% 0;
}

.mat-ruler-y {
  left: 16px;
  translate: 0 -50%;
}

.mat-cutout {
  display: block;
  width: min(46%, 280px);
  rotate: -6deg;
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.25)) drop-shadow(0 18px 22px rgb(0 0 0 / 0.35));
  transition:
    rotate 0.5s var(--ease-spring),
    translate 0.5s var(--ease-spring),
    filter 0.4s var(--ease-out);
}

/* The white die-cut border, like Mat's own cutouts */
.mat-sticker {
  display: block;
  padding: 4%;
  background: #ffffff;
  -webkit-mask: url(assets/squircle.svg) center / 100% 100% no-repeat;
  mask: url(assets/squircle.svg) center / 100% 100% no-repeat;
}

.stage-mat:hover .mat-cutout {
  rotate: -2deg;
  translate: 0 -8px;
  filter: drop-shadow(0 4px 4px rgb(0 0 0 / 0.22)) drop-shadow(0 34px 32px rgb(0 0 0 / 0.38));
}

/* Melt: red ground, white lowercase serif, hold to melt. */
.stage-melt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  padding: var(--space-xl);
  background: var(--melt-ground);
  color: var(--melt-ink);
  text-align: center;
}

.melt-line {
  max-width: 11ch;
  font-family: var(--font-melt);
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: lowercase;
  transform-origin: 50% 0;
  transition:
    opacity 0.6s var(--ease-out),
    filter 0.5s var(--ease-out),
    transform 0.6s var(--ease-spring);
}

.stage-melt[data-phase="melting"] .melt-line {
  opacity: 0;
  filter: blur(10px);
  transform: translateY(40%) scaleY(1.6);
  transition:
    opacity 2.2s cubic-bezier(0.7, 0, 1, 0.6),
    filter 2.2s cubic-bezier(0.55, 0, 0.9, 0.4),
    transform 2.2s cubic-bezier(0.6, 0, 0.9, 0.5);
}

.stage-melt[data-phase="gone"] .melt-line {
  opacity: 0;
  transition: none;
}

/* Liquid-glass-ish control, echoing the app's glass melt button */
.melt-button {
  appearance: none;
  height: 52px;
  padding-inline: 26px;
  border: 1px solid rgb(255 255 255 / 0.45);
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.16);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.5),
    0 8px 24px -8px rgb(0 0 0 / 0.35);
  color: var(--melt-ink);
  font: 500 15px var(--font-sans);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    background 0.2s,
    scale 0.3s var(--ease-spring);
}

.melt-button:hover {
  background: rgb(255 255 255 / 0.22);
}

.stage-melt[data-phase="melting"] .melt-button {
  scale: 0.94;
  background: rgb(255 255 255 / 0.28);
}

.melt-button:focus-visible {
  outline-color: var(--melt-ink);
}

.melt-count {
  position: absolute;
  right: 0;
  bottom: 20px;
  left: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.75);
}

/* ---------- How we work ---------- */

.how,
.about {
  padding-block: var(--section);
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  align-content: start;
  gap: var(--space-md);
}

.section-title {
  max-width: 16ch;
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.principles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--line);
}

.principles li {
  display: grid;
  align-content: start;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-xl) var(--space-xl) 0;
  border-bottom: 1px solid var(--line);
}

.principles li:nth-child(even) {
  padding-right: 0;
  padding-left: var(--space-xl);
  border-left: 1px solid var(--line);
}

.principles h3 {
  margin-top: var(--space-sm);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.principles p {
  max-width: 44ch;
  color: var(--ink-soft);
}

/* ---------- About ---------- */

.about {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(32px, 6vw, 96px);
}

.letter {
  display: grid;
  gap: var(--space-lg);
  font-size: clamp(19px, 1.8vw, 22px);
  line-height: 1.55;
  letter-spacing: -0.01em;
}

.signature {
  margin-top: var(--space-sm);
  font-family: var(--font-accent);
  font-size: 34px;
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.letter .link {
  justify-self: start;
}

/* ---------- Footer ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-block: var(--space-xl) var(--space-2xl);
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
}

.footer-links a {
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--ink);
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .feature,
  .feature-flip,
  .about {
    grid-template-columns: minmax(0, 1fr);
  }

  .feature-flip .feature-copy {
    order: 0;
  }

  .stage {
    aspect-ratio: 1;
  }
}

@media (max-width: 760px) {
  .principles {
    grid-template-columns: minmax(0, 1fr);
  }

  .principles li,
  .principles li:nth-child(even) {
    padding: var(--space-lg) 0;
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding-inline: 20px;
  }

  .nav {
    display: none;
  }

  .brand {
    font-size: 14px;
  }

  .shelf-grid {
    gap: var(--space-md);
  }

  /* A real home screen only shows names */
  .slot-status {
    display: none;
  }

  .slot-name {
    font-size: 13px;
  }

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

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .pretty-underline path {
    animation: none;
    stroke-dashoffset: 0;
  }

  .slot:hover .icon-object,
  .slot:focus-visible .icon-object {
    animation: none;
  }

  .stage-melt[data-phase="melting"] .melt-line {
    filter: none;
    transform: none;
  }
}
