/* Teyra - games and apps in two tabs.
   Built 1:1 on the 1600px mockup: 1u = 1px at 1600px wide and up,
   below that everything scales down (fonts keep readable minimums), phones get their own layout.
   Font metric constants: Garamond, line-height 1 - baseline 0.7993em from the top of the box,
   0.2007em from the bottom. Segoe UI, line-height 1 - baseline 0.9141em from the top.
   Plain numbers next to var(--u) are pixel rows of the mockup (baselines, lines, image edges). */

:root {
  /* Colours of the Teyra logo (indigo #201d4d, lavender #ddd1f3) on a very dark violet */
  --bg: #201d30;
  --text: #ddd1f3;
  --muted: #a698c8;
  --line: #423c5d;
  --accent: #c9b8ed;
  --indigo: #201d4d;
  --text-hover: #f3eefc;
  --img-bg: #27233a;
  --serif: Garamond, "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  /* Game descriptions: EB Garamond first (Google Fonts, with italics and Cyrillic), not the local Windows Garamond */
  --serif-text: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;

  --u: min(1px, 0.0625vw);

  --fs-brand: max(36px, calc(56.75 * var(--u)));
  --fs-lang: max(15px, calc(20.5 * var(--u)));
  --fs-tab: max(26px, calc(43.5 * var(--u)));
  --fs-card: max(21px, calc(38.25 * var(--u)));

  --gap: max(14px, calc(24 * var(--u)));
}

*,
*::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(--sans);
  font-size: 16px;
  line-height: 1.4;
  font-kerning: normal;
}

img,
video {
  display: block;
  max-width: 100%;
}

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

h1,
h2,
p {
  margin: 0;
  font-weight: 400;
}

button {
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 400;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 4px;
}

/* Selected text looks like the logo: indigo on lavender */
::selection {
  background: var(--text);
  color: var(--indigo);
}

/* The page is lined up with the whole window (100vw), not with the area left of the scrollbar:
   this way it sits exactly as in the mockup and does not shift sideways
   when the scrollbar comes and goes between the tall Games tab and the short Apps tab. */
.wrap {
  width: calc(1452 * var(--u));
  margin-left: calc((100vw - 1452 * var(--u)) / 2);
}

/* Thin lines under the header and under the tabs (1px longer on the right, as in the mockup) */

.masthead,
.tabs {
  position: relative;
}

.masthead::after,
.tabs::after {
  content: "";
  position: absolute;
  left: 0;
  right: calc(-1 * var(--u));
  bottom: 0;
  height: 1px;
  background: var(--line);
}

/* Header: Teyra + language switch */

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: calc((109 - 76.6) * var(--u) - 0.2007 * var(--fs-brand));
}

.brand {
  margin-top: calc(76.6 * var(--u) - 0.7993 * var(--fs-brand));
  font-family: var(--serif);
  font-size: var(--fs-brand);
  line-height: 1;
}

.lang {
  display: flex;
  gap: max(14px, calc(27 * var(--u)));
  margin-top: calc(69 * var(--u) - 0.9141 * var(--fs-lang));
  margin-right: calc(1.5 * var(--u));
  font-family: var(--sans);
  font-size: var(--fs-lang);
  line-height: 1;
}

.lang button {
  position: relative;
  margin: -8px -6px;
  padding: 8px 6px;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  transition: color 0.2s;
}

.lang button:hover,
.lang button[aria-pressed="true"] {
  color: var(--text);
}

.lang button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: calc(8px + 0.9141em + 10 * var(--u));
  left: calc(6px + 3.5 * var(--u));
  right: calc(6px - 1.5 * var(--u));
  height: max(1px, calc(2 * var(--u)));
  background: var(--accent);
}

/* Tabs */

.tabs {
  display: flex;
  gap: calc(49.5 * var(--u));
}

.tab {
  position: relative;
  padding: calc((171.2 - 109) * var(--u) - 0.7993 * var(--fs-tab)) 0 calc((195 - 171.2) * var(--u) - 0.2007 * var(--fs-tab));
  color: var(--muted);
  font-family: var(--serif);
  font-size: var(--fs-tab);
  line-height: 1;
  transition: color 0.2s;
}

.tab:hover,
.tab[aria-selected="true"] {
  color: var(--text);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 0;
  right: calc(-2 * var(--u));
  bottom: calc(-1 * var(--u));
  height: max(2px, calc(3 * var(--u)));
  background: var(--accent);
}

.tab:focus-visible {
  outline-offset: 2px;
}

/* Panels: all cards are the same size - the small card of the mockup (468 x 219 at 1600px), three in a row */

main {
  padding-bottom: calc(50.3 * var(--u) - 0.2007 * var(--fs-card));
}

.panel {
  padding-top: calc((224 - 195) * var(--u));
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--gap);
  /* 39.3 from a title's baseline down to the next row of pictures */
  row-gap: calc(39.3 * var(--u) - 0.2007 * var(--fs-card));
}

/* Cards. Game cards show a short video (with its first frame as the poster), app cards a picture */

.card {
  position: relative;
  min-width: 0;
}

.card-img {
  width: 100%;
  height: auto;
  aspect-ratio: 468 / 219;
  object-fit: cover;
  background-color: var(--img-bg);
}

/* Title baseline 42.7 below the picture */
.card-title {
  margin-top: max(0.2em, calc(42.7 * var(--u) - 0.7993em));
  font-family: var(--serif);
  font-size: var(--fs-card);
  line-height: 1;
}

/* Cards with a link: the whole card is clickable */
.card--link .card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card--link .card-title a:focus-visible {
  outline: none;
}

.card--link .card-title a:focus-visible::after {
  outline: 1px solid var(--text);
  outline-offset: 6px;
}

.card--link .card-img {
  transition: filter 0.25s;
}

.card--link:hover .card-img {
  filter: brightness(1.08);
}

.card--link:hover .card-title {
  color: var(--text-hover);
}

/* Project pages (games/..., apps/...): the same header, a link back, the name and (games only, for now) a big picture */

/* The link back sits on the same baseline as the tab names on the home page */
.page {
  padding-top: calc((171.2 - 109) * var(--u) - 0.9141 * var(--fs-lang));
  padding-bottom: max(48px, calc(120 * var(--u)));
}

.back {
  font-family: var(--sans);
  font-size: var(--fs-lang);
  line-height: 1;
}

.back a {
  margin: -8px -6px;
  padding: 8px 6px;
  color: var(--muted);
  transition: color 0.2s;
}

.back a:hover,
.back a:focus-visible {
  color: var(--text);
}

/* The name: baseline 100 below the link back */
.page-title {
  margin-top: max(0.3em, calc(100 * var(--u) - (1 - 0.9141) * var(--fs-lang) - 0.7993em));
  font-family: var(--serif);
  font-size: max(40px, calc(72 * var(--u)));
  line-height: 1;
}

/* The game's picture under its name: as wide as two cards of the home page (960 at 1600px) */
.page-img {
  width: calc(960 * var(--u));
  height: auto;
  margin-top: max(20px, calc(40 * var(--u)));
  background-color: var(--img-bg);
}

/* Game description (games/...): tagline under the name, then the picture, lead, About, How to play,
   Controls, Features, Details. Only type and thin lines - no boxes or icons.
   From 1100px wide the lead stands to the right of the picture and Details to the right of About;
   narrower, everything goes in one column under the picture. */

.page-tagline {
  margin-top: max(10px, calc(22 * var(--u)));
  font-family: var(--serif-text);
  font-size: max(18px, calc(26 * var(--u)));
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-wrap: balance;
}

.game,
.legal {
  margin-top: max(20px, calc(40 * var(--u)));
  font-family: var(--serif-text);
  font-size: max(19px, calc(24 * var(--u)));
  line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
}

.game > .page-img {
  margin-top: 0;
}

.game-lead {
  max-width: 24em;
  margin-top: max(24px, calc(40 * var(--u)));
  font-size: max(21px, calc(32 * var(--u)));
  line-height: 1.38;
  text-wrap: balance;
}

/* About ... Details: about 60-68 characters a line (English ~67, Ukrainian ~60) */
.game-sec {
  max-width: 25em;
  margin-top: max(36px, calc(64 * var(--u)));
}

.game h2,
.legal h2 {
  margin-bottom: max(10px, calc(16 * var(--u)));
  padding-top: max(12px, calc(18 * var(--u)));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: max(18px, calc(25 * var(--u)));
  line-height: 1.25;
  letter-spacing: 0.06em;
  text-wrap: balance;
}

.game-sec p,
.steps li,
.features li {
  text-wrap: pretty;
  hyphens: auto;
  hyphenate-limit-chars: 8 4 4;
}

.game-sec p + p {
  margin-top: 0.75em;
}

/* How to play: a real <ol>, numbered by the page (serif figures in the accent colour), thin lines between steps */
.steps,
.features {
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps {
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0.45em 0 0.45em 1.9em;
  counter-increment: step;
}

.steps li:first-child {
  padding-top: 0;
}

.steps li + li {
  border-top: 1px solid var(--line);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 0.45em;
  left: 0.15em;
  color: var(--accent);
  font-variant-numeric: lining-nums;
}

.steps li:first-child::before {
  top: 0;
}

/* Features: the term in italics on its own line, then one sentence */
.features li + li {
  margin-top: 0.8em;
}

.features strong {
  display: block;
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
}

/* Controls and Details: two columns, thin lines between the rows */
.keys,
.details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0;
}

.keys > div,
.details > div {
  display: contents;
}

.keys dt,
.keys dd,
.details dt,
.details dd {
  margin: 0;
  padding: 0.4em 0;
  border-top: 1px solid var(--line);
}

.keys > div:first-child > *,
.details > div:first-child > * {
  padding-top: 0;
  border-top: 0;
}

/* The gap sits inside the first column, so each row's line runs unbroken */
.keys dt,
.details dt {
  padding-right: 1.1em;
  color: var(--muted);
}

.details dt {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
}

/* A key: thin frame, the picture background; inline, so it does not change the line height */
.game kbd {
  padding: 0.12em 0.45em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background-color: var(--img-bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.7em;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (min-width: 1100px) {
  .game {
    display: grid;
    grid-template-columns: calc(960 * var(--u)) minmax(0, 1fr);
    column-gap: calc(64 * var(--u));
    align-items: start;
  }

  .game > * {
    grid-column: 1;
  }

  /* The lead: to the right of the picture, its first line level with the picture's top edge */
  .game > .game-lead {
    grid-column: 2;
    grid-row: 1;
    margin-top: -0.38em;
  }

  /* Details: to the right of About */
  .game > .game-details {
    grid-column: 2;
    grid-row: 2 / span 6;
  }
}

/* Links inside the text: the accent colour, underlined */
.game a,
.legal a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.2s;
}

.game a:hover,
.game a:focus-visible,
.legal a:hover,
.legal a:focus-visible {
  color: var(--text-hover);
}

/* Under Details: the link to the game's privacy policy, after a thin line like the rows above */
.game-legal {
  padding-top: 0.4em;
  border-top: 1px solid var(--line);
}

/* Privacy policy (games/<slug>/privacy/): the date under the name, then one column of text in the type
   of the game description - the short version as the lead, then the sections */
.legal-date {
  margin-top: max(10px, calc(22 * var(--u)));
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-lang);
  line-height: 1.4;
}

.legal > :first-child {
  margin-top: 0;
}

.legal .features {
  margin-top: 0.75em;
}

/* Footer: contacts under a thin line */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: max(20px, calc(40 * var(--u)));
  row-gap: 6px;
  padding: max(20px, calc(36 * var(--u))) 0 max(32px, calc(64 * var(--u)));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-lang);
  line-height: 1.4;
}

.footer a {
  transition: color 0.2s;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--text);
}

/* Phones */

@media (max-width: 700px) {
  :root {
    --fs-brand: 38px;
    --fs-lang: 15px;
    --fs-tab: 28px;
    --fs-card: 26px;
    --gap: 30px;
  }

  .wrap {
    width: calc(100% - 40px);
    margin-inline: auto;
  }

  .masthead {
    align-items: center;
    padding-top: 22px;
    padding-bottom: 16px;
  }

  .brand,
  .lang {
    margin-top: 0;
  }

  .lang button[aria-pressed="true"]::after {
    top: calc(8px + 0.9141em + 7px);
    left: 8px;
    right: 5px;
  }

  .tabs {
    gap: 30px;
  }

  .tab {
    padding: 18px 0 14px;
  }

  .panel {
    padding-top: 24px;
  }

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

  .card-title {
    margin-top: 12px;
  }

  main {
    padding-bottom: 48px;
  }

  .page {
    padding-top: 28px;
    padding-bottom: 56px;
  }

  .page-title {
    margin-top: 16px;
    font-size: 44px;
  }

  .page-img {
    width: 100%;
  }

  /* One line each: Contact, then the addresses */
  .footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 0 32px;
  }
}
