/* ==========================================================================
   Suomen Suuhengitysliitto Ry
   ========================================================================== */

/* ---------- Design tokens ---------- */

:root {
  /* Colour: an off-white page and near-black ink, softened just enough to rest the eyes. */
  --color-paper: #fbfbf9;
  --color-ink: #121212;
  --color-ink-muted: #6b6b6a;

  /* Type */
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --weight-light: 300;
  --weight-regular: 400;
  --weight-medium: 500;
  --size-title: clamp(2rem, 1rem + 4.6vw, 4.75rem);
  --size-heading: clamp(1.875rem, 1.25rem + 2.2vw, 3.25rem);
  --size-body: clamp(1rem, 0.94rem + 0.25vw, 1.1875rem);
  --size-small: 0.875rem;
  --tracking-tight: -0.035em;
  --tracking-wide: 0.03em;

  /* Layout */
  --gutter: clamp(1rem, 4vw, 3rem);
  --content-width: min(90%, 42rem);
  --title-gap: clamp(2.5rem, 7vh, 4.5rem); /* between the landing title and its button */
  --touch-target: 2.75rem;
  --icon-size: 1.25rem;

  /* Motion: a view fades out, then the next one reveals its heading, then the rest. */
  --leave-duration: 0.6s;
  --reveal-duration: 1.1s;
  --reveal-distance: 0.6rem;
  --reveal-blur: 6px;
  --ease-reveal: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-leave: cubic-bezier(0.65, 0, 0.35, 1);
}

@media (min-width: 70em) {
  :root {
    --content-width: 60%;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --reveal-distance: 0;
    --reveal-blur: 0;
  }
}

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

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

html {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none; /* no bounce or pull-to-refresh: scrolling switches pages */
}

body {
  margin: 0;
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
  line-height: 1.75;
}

h1,
p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

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

:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 0.375rem;
}

[tabindex="-1"]:focus {
  outline: none;
}

/* ---------- Reveal ---------- */

/* Elements fade in when their view is shown; late ones start when the first ones finish. */
.reveal {
  animation: reveal var(--reveal-duration) var(--ease-reveal) both;
}

.reveal--late {
  animation-delay: var(--reveal-duration);
}

/* Held back until the fonts have loaded (see main.js). */
.is-loading .reveal {
  animation-play-state: paused;
}

@keyframes reveal {
  from {
    opacity: 0;
    visibility: hidden; /* not clickable before it starts to appear */
    transform: translateY(var(--reveal-distance));
    filter: blur(var(--reveal-blur));
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    visibility: hidden;
  }
}

/* ---------- Views ---------- */

.view {
  min-height: 100vh;
  min-height: 100dvh;
  transition: opacity var(--leave-duration) var(--ease-leave);
}

.view.is-leaving {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Landing ---------- */

/* Two equal rows around a gap, so the space between the title and the button is mid-screen. */
.landing {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  row-gap: var(--title-gap);
  justify-items: center;
  padding-inline: var(--gutter);
}

.landing__title {
  align-self: end;
  font-size: var(--size-title);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tight);
  line-height: 1.05;
  text-align: center;
  text-wrap: balance;
}

.landing__start {
  align-self: start;
  animation-name: fade-in;
}

/*
 * The whole page is the start button's hit area. This is also why only opacity animates on the
 * button: a transform or filter on it (or its ancestors) would trap this fixed overlay inside it.
 */
.landing__start::after {
  content: "";
  position: fixed;
  inset: 0;
}

/* ---------- Button ---------- */

.button {
  padding: 1.05em 2.25em;
  border: 1px solid var(--color-ink);
  border-radius: 999px;
  background: transparent;
  color: var(--color-ink);
  font: inherit;
  font-size: var(--size-small);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.25s,
    color 0.25s;
}

.button:active {
  background: var(--color-ink);
  color: var(--color-paper);
}

/* ---------- Content pages ---------- */

.site {
  position: relative;
  display: grid;
  place-items: center;
  padding-block: calc(var(--gutter) + var(--touch-target) + 1rem);
}

.site__main {
  width: var(--content-width);
}

.page__title {
  margin-bottom: clamp(1.25rem, 3.5vh, 2.25rem);
  font-size: var(--size-heading);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  text-wrap: balance;
}

.page__body > * + * {
  margin-top: 1.25em;
}

.page__body p {
  text-wrap: pretty;
}

/* ---------- Menu ---------- */

.menu__list {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu__link {
  display: block;
  color: var(--color-ink-muted);
  font-size: var(--size-small);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s;
}

.menu__link:hover,
.menu__link[aria-current="page"] {
  color: var(--color-ink);
}

.menu__icon {
  display: block;
  width: var(--icon-size);
  height: var(--icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu__icon-dot {
  fill: currentColor;
  stroke: none;
}

/* Phones and tablets: a row of icons in the top right corner. */
@media (max-width: 69.999em) {
  .menu {
    position: absolute;
    top: var(--gutter);
    right: calc(var(--gutter) - (var(--touch-target) - var(--icon-size)) / 2);
  }

  .menu__link {
    display: grid;
    place-items: center;
    width: var(--touch-target);
    height: var(--touch-target);
  }

  /* Hidden visually, still read by screen readers. */
  .menu__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

/* Desktop: text links down the right side. */
@media (min-width: 70em) {
  .menu {
    position: fixed;
    top: 50%;
    right: var(--gutter);
    translate: 0 -50%;
  }

  .menu__list {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
  }

  .menu__link {
    padding-block: 0.25rem;
  }

  .menu__icon {
    display: none;
  }
}
