/* Textra site. Values come from the Figma mockup ("small site", 1280 px wide):
   content column 1008 px, 80 px top padding, 40 px between hero and demo. */

/* ─── Colors: light theme by default, dark one follows the system setting ─── */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted-opacity: 0.6;             /* secondary text in the mockup is #1a1a1a at 60% */
  --button-bg: #1a1a1a;
  --button-bg-hover: #333333;
  --button-text: #ffffff;
  --border: rgba(26, 26, 26, 0.1);
  --tab-bg: #ffffff;
  --tab-fill: rgba(26, 26, 26, 0.05); /* progress fill inside the active tab */
  --icon-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
  --media-bg: #d9d2c7;              /* shows for a moment before the background image loads */

  --font: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --text: #f2f2f2;
    --button-bg: #f2f2f2;
    --button-bg-hover: #ffffff;
    --button-text: #1a1a1a;
    --border: rgba(255, 255, 255, 0.12);
    --tab-bg: #111111;
    --tab-fill: rgba(255, 255, 255, 0.08);
    --icon-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    --media-bg: #2a2724;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg { display: block; }

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

/* ─── Page column ─── */
.page {
  max-width: calc(1008px + 2 * 24px);
  margin: 0 auto;
  /* env(): keep clear of the notch in landscape on iPhone */
  padding: 80px max(24px, env(safe-area-inset-right)) 16px max(24px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ─── Hero ─── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.app-icon {
  width: 80px;
  height: 80px;
  border-radius: 20.763px;          /* 26% of the size, as in the mockup */
  box-shadow: var(--icon-shadow);
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

h1 {
  margin: 0;
  font-family: var(--font-rounded);
  font-weight: 600;                 /* Semibold */
  font-size: 32px;
  line-height: 1.2;
  text-wrap: balance;               /* even line lengths when the headline wraps */
}

.subtitle {
  margin: 0;
  opacity: var(--muted-opacity);
  text-wrap: pretty;
}

.cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;                 /* comfortable tap target */
  padding: 12px 20px;
  border-radius: 100px;
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 16px;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.button:hover { background: var(--button-bg-hover); }
.button:active { transform: scale(0.97); }

.button-icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: currentColor;
  margin-top: -2px;                 /* the Apple logo sits a bit high otherwise */
}

.button-share .button-icon {
  fill: none;
  width: 17px;
  height: 17px;
}

/* Which button to show. Touch-only devices (phones, iPads) can't install a Mac app,
   so they get "Send link to your Mac" instead of a download that goes nowhere. */
.button-share { display: none; }

@media (hover: none) and (pointer: coarse) {
  .button-download { display: none; }
  .button-share { display: inline-flex; }
}

.fineprint {
  margin: 0;
  font-size: 14px;
  line-height: normal;
  opacity: var(--muted-opacity);
}

/* ─── Demo: video card + tabs ─── */
.demo {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
}

.media {
  position: relative;
  aspect-ratio: 1008 / 640;         /* same shape as the 1700×1080 videos */
  border-radius: 16px;
  overflow: hidden;
  background: var(--media-bg) url("assets/card-bg.webp") center / cover no-repeat;
  /* Safari: keep video corners rounded while it plays */
  isolation: isolate;
  transform: translateZ(0);
}

/* One slide per tab, stacked. Switching: the new slide fades in ON TOP of the old one,
   which stays fully visible underneath until the fade ends. So the picture goes straight
   from the old video's current frame to the new video's first frame: no gap, no dimming. */
.slide {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  visibility: hidden;
}

.slide.is-leaving {                 /* the previous slide, under the new one */
  z-index: 1;
  opacity: 1;
  visibility: visible;
}

.slide.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}

/* .frame holds the poster and the video. On desktop it fills the slide;
   on phones it's the rounded box of each video (see "Phones" below). */
.frame {
  position: absolute;
  inset: 0;
}

.frame .poster,
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The video stays invisible until it really plays, so the poster (its first frame)
   shows meanwhile and nothing flashes black. */
.frame video { opacity: 0; transition: opacity 0.2s ease; }
.frame video.is-ready { opacity: 1; }

.caption { display: none; }        /* desktop: the tabs carry the text */

/* Pause / play button over the video */
.play-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #ffffff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.15s ease;
}

.play-toggle[hidden] { display: none; }
.play-toggle:hover { background: rgba(0, 0, 0, 0.6); }
.play-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.play-toggle .icon-play { display: none; }
.play-toggle.is-paused .icon-play { display: block; }
.play-toggle.is-paused .icon-pause { display: none; }

/* Visible on hover, on keyboard focus, when paused, and always on touch screens */
.media:hover .play-toggle,
.play-toggle:focus-visible,
.play-toggle.is-paused { opacity: 1; }

@media (hover: none) { .play-toggle { opacity: 0.9; } }

/* Tabs */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.tab {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--tab-bg);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Progress fill: grows from the left while the tab's video plays.
   script.js sets --progress from 0 to 1. transform is cheaper than width. */
.tab::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tab-fill);
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
}

.tab-icon,
.tab-label { position: relative; } /* above the fill */

.tab-icon {
  height: 24px;
  width: auto;                      /* 20 or 30 px wide, from each icon's viewBox */
  flex: none;
  fill: currentColor;               /* follows the theme */
  opacity: var(--muted-opacity);    /* same as the label: 60%, full in the active tab */
  transition: opacity 0.2s ease;
}

.tab-label {
  opacity: var(--muted-opacity);
  transition: opacity 0.2s ease;
}

.tab:hover .tab-label,
.tab:hover .tab-icon { opacity: 0.8; }
.tab[aria-selected="true"] .tab-label,
.tab[aria-selected="true"] .tab-icon { opacity: 1; }

.privacy {
  margin: 12px 0 0;                /* 24 px under the tabs together with the gap */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: var(--muted-opacity);   /* icon and text together, like the icon's own 60% */
  text-wrap: balance;
}

.privacy-icon {
  flex: none;
  fill: currentColor;              /* follows the theme */
}

/* ─── Footer ─── */
.footer {
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  opacity: var(--muted-opacity);
}

/* ─── Phones ─── */
@media (max-width: 700px) {
  .page {
    padding-top: 48px;
    gap: 32px;
  }

  .app-icon {
    width: 72px;
    height: 72px;
    border-radius: 18.7px;
  }

  h1 { font-size: 28px; }

  .demo { padding-bottom: 48px; }

  /* No tabs on phones: the three videos stack, each with its caption underneath,
     and each loops on its own while it's on screen (script.js). */
  .media {
    aspect-ratio: auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow: visible;
    background: none;
    border-radius: 0;
    transform: none;
  }

  .slide,
  .slide.is-active,
  .slide.is-leaving {
    position: static;
    opacity: 1;
    visibility: visible;
    transition: none;
  }

  .frame {
    position: relative;
    aspect-ratio: 1700 / 1080;
    border-radius: 12px;
    overflow: hidden;
    background: var(--media-bg) url("assets/card-bg.webp") center / cover no-repeat;
    isolation: isolate;
  }

  .caption {
    display: block;
    margin: 12px 0 0;
    text-align: center;
  }

  .tabs,
  .play-toggle { display: none; }  /* a tap on a video pauses or plays it instead */

  /* Two lines of text next to an icon look lopsided on a narrow screen: icon on top. */
  .privacy {
    margin-top: 8px;
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }
}

/* ─── Apple-style continuous corners ───
   corner-shape bends the corner as a superellipse: the curve starts earlier and eases
   into the straight edge, like iPhone and Mac cards and icons, not a quarter circle.
   superellipse(1.5) is closest to Apple's shape; "squircle" (2) looks too boxy.
   The curve is flatter, so the radius is 1.5× larger to look the same size as the mockup.
   Browsers without corner-shape (Safari and Firefox for now) keep the plain radii above. */
@supports (corner-shape: superellipse(1.5)) {
  .app-icon, .media, .tab { corner-shape: superellipse(1.5); }
  /* Chrome doesn't clip a video to a corner-shaped parent (the corners come out square),
     so the slides, posters and videos take the same shape themselves. */
  .slide,
  .frame,
  .frame .poster,
  .frame video { border-radius: inherit; corner-shape: inherit; }
  .app-icon { border-radius: 31px; }   /* 20.763 × 1.5 */
  .media,
  .tab { border-radius: 24px; }        /* 16 × 1.5 */

  @media (max-width: 700px) {
    .app-icon { border-radius: 28px; } /* 18.7 × 1.5 */
    .media { border-radius: 0; corner-shape: round; }
    .frame { border-radius: 18px; corner-shape: superellipse(1.5); } /* 12 × 1.5 */
  }
}

/* ─── Reduced motion: no crossfades; script.js also turns off autoplay ─── */
@media (prefers-reduced-motion: reduce) {
  .slide, .slide.is-active, .frame video, .tab-label, .tab-icon, .button { transition: none; }
}
