/* youtopialabs.com (web-live). LogPal's Sunset Coral, as docs/design-system.md
   gives it: the tokens of section 2, Source Serif 4 for display and the system
   UI font for everything else (section 3), radii of section 5. The font is
   served from this site, so a page asks nothing of any other server. */

@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/source-serif-4-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #FFF8F1;
  --bg-elevated: #FFFFFF;
  --bg-sunken: #FBF1E2;
  --bg-subtle: #FFF3EA;
  --brand: #F4502E;
  --brand-hover: #D83E1E;
  --brand-soft: #FDE5DE;
  --brand-softer: #FFF1ED;
  --on-brand: #FFFFFF;
  --text: #2A1A10;
  --text-2: #6E5849;
  --text-3: #A89180;
  --border: #EFD3AC;
  --border-strong: #E4BE88;
  --divider: #EEDCBE;
  --shadow: 0 1px 2px rgba(60, 40, 30, 0.06), 0 6px 18px rgba(60, 40, 30, 0.06);
  --topbar: rgba(255, 248, 241, 0.88);
  --link-line: rgba(42, 26, 16, 0.30);   /* a link's underline: its own ink, faint (Ham, 24 November: not coral, not thick) */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", "Sukhumvit Set", Thonburi, "Noto Sans Thai", system-ui, sans-serif;
  --font-display: "Source Serif 4", ui-serif, Georgia, "Sukhumvit Set", Thonburi, "Noto Sans Thai", serif;
  --gutter: 24px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16110B;
    --bg-elevated: #211A12;
    --bg-sunken: #0F0B07;
    --bg-subtle: #2A2117;
    --brand: #FF7A5C;
    --brand-hover: #FF9070;
    --brand-soft: #3A201A;
    --brand-softer: #2A1712;
    --on-brand: #1A0F08;
    --text: #F4ECDD;
    --text-2: #AC9B85;
    --text-3: #7A6A5C;
    --border: #2E2620;
    --border-strong: #3F362C;
    --divider: #26201A;
    --shadow: none;
    --topbar: rgba(22, 17, 11, 0.88);
    --link-line: rgba(244, 236, 221, 0.32);
  }
}

/* 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-ui);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

img, svg { max-width: 100%; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--link-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a:hover { text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 6px;
}

h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* Thai reads best with more room between lines. Set on the blocks only: a
   Thai span inside a heading takes the heading's own line height. */
html:lang(th) body, article:lang(th) { line-height: 1.8; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 20;
  background: var(--bg-elevated);
  padding: 8px 14px;
  border-radius: 10px;
}

/* One language at a time once the script has picked one; both without it. */

html[data-lang="en"] [data-lang="th"],
html[data-lang="th"] [data-lang="en"] { display: none !important; }
html:not(.js) .lang-switch { display: none; }
html:not([data-lang]) article[data-lang="th"] {
  border-top: 1px solid var(--divider);
  margin-top: 48px;
  padding-top: 24px;
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--divider);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text);
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
}
.brand:hover { color: var(--text); }

.lang-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 999px;
}
.lang-switch button {
  font: inherit;
  font-size: 0.875rem;
  line-height: 1;
  padding: 8px 14px;
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(60, 40, 30, 0.12);
}

/* Footer */

.foot {
  margin-top: 72px;
  border-top: 1px solid var(--divider);
  background: var(--bg-sunken);
  padding-block: 32px calc(32px + env(safe-area-inset-bottom, 0px));
  font-size: 0.9375rem;
  color: var(--text-2);
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-bottom: 16px;
}
.foot-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.foot-links a:hover { text-decoration-line: underline; text-decoration-color: var(--link-line); }
.foot p { margin: 0 0 6px; }
.foot .fine { color: var(--text-2); }

/* Shared pieces */

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
}
.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 14px;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
}
.button:hover { background: var(--brand-hover); color: var(--on-brand); }

/* Documents: privacy, terms, support, health data */

.doc-page { padding-top: 40px; }
.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "main";
  max-width: 720px;
  margin-inline: auto;
}
.doc-head { grid-area: head; margin-bottom: 8px; }
.doc-head h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 1.4rem + 2.6vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.updated { margin: 0; color: var(--text-2); font-size: 0.9375rem; }
.doc-main { grid-area: main; min-width: 0; }
.toc-side { display: none; }

.toc-inline {
  margin: 24px 0 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.toc-inline summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s;
}
.toc-inline[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.toc-inline ol { margin: 0; padding: 0 16px 14px 16px; }

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}
.toc li + li { margin-top: 8px; }
.toc a { text-decoration: none; color: var(--text-2); }
.toc a:hover { color: var(--text); text-decoration-line: underline; text-decoration-color: var(--link-line); }

@media (min-width: 1040px) {
  .doc {
    max-width: none;
    grid-template-columns: 232px minmax(0, 700px);
    grid-template-areas: "toc head" "toc main";
    column-gap: 72px;
    justify-content: center;
  }
  .doc.no-toc {
    grid-template-columns: minmax(0, 720px);
    grid-template-areas: "head" "main";
  }
  .toc-side {
    display: block;
    grid-area: toc;
    position: sticky;
    top: 92px;
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow: auto;
    padding-top: 10px;
  }
  .toc-side p {
    margin: 0 0 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-2);
  }
  .toc-inline { display: none; }
}

.prose { margin-top: 28px; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul { margin: 0 0 1em; }
.prose h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 2.2em 0 0.6em;
  scroll-margin-top: 84px;
}
.prose h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.8em 0 0.35em;
}
.prose h3 + p { margin-top: 0; }
.prose ul { padding-left: 1.25em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--brand); }
.prose strong { font-weight: 600; }

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.25em;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.5;
}
.table-wrap th, .table-wrap td {
  text-align: left;
  vertical-align: top;
  padding: 11px 16px;
  border-bottom: 1px solid var(--divider);
}
.table-wrap th {
  background: var(--bg-subtle);
  font-weight: 600;
  white-space: nowrap;
}
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:first-child { min-width: 9.5em; }

.qr {
  margin: 0 0 1.25em;
  display: inline-block;
  padding: 14px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.qr img { display: block; width: 176px; height: 176px; }

/* LogPal's page */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding-top: 28px;
  padding-bottom: 24px;
  align-items: center;
}
.hero-art {
  position: relative;
  justify-self: center;
  width: min(62vw, 260px);
  order: -1;
}
.hero-art::before {
  content: "";
  position: absolute;
  inset: 6% -10% -4%;
  background: radial-gradient(closest-side, var(--brand-soft), transparent);
  z-index: -1;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 1.3rem + 3.6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0 0 18px;
}
.hero .lead {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0 0 24px;
  max-width: 34em;
}
.store {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0;
}
.store .for { color: var(--text-2); font-size: 0.9375rem; }

@media (min-width: 820px) {
  .hero {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 48px;
    padding-top: 64px;
    padding-bottom: 56px;
  }
  .hero-art { order: 0; width: min(100%, 400px); }
}

.loggy { display: block; width: 100%; height: auto; overflow: visible; }
.loggy .lg-tail {
  transform-origin: 745px 1705px;
  animation: lg-tail 3.4s ease-in-out infinite alternate;
}
.loggy .lg-arm {
  transform-origin: 1176px 1300px;
  animation: lg-wave 2.6s ease-in-out 0.7s 1 both;
}
.loggy .lg-head {
  transform-origin: 956px 1280px;
  animation: lg-tilt 2.6s ease-in-out 0.7s 1 both;
}
.loggy .lg-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: lg-blink 5.2s ease-in-out 2.4s infinite;
}
@keyframes lg-tail {
  from { transform: rotate(-3deg); }
  to { transform: rotate(4deg); }
}
@keyframes lg-wave {
  0% { transform: rotate(0deg); }
  18% { transform: rotate(-40deg); }
  32% { transform: rotate(-28deg); }
  46% { transform: rotate(-42deg); }
  60% { transform: rotate(-29deg); }
  74% { transform: rotate(-38deg); }
  100% { transform: rotate(0deg); }
}
@keyframes lg-tilt {
  0%, 100% { transform: rotate(0deg); }
  20%, 76% { transform: rotate(4deg); }
}
@keyframes lg-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.12); }
}
@media (prefers-reduced-motion: reduce) {
  .loggy * { animation: none !important; }
}

.features {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding-top: 16px;
}
@media (min-width: 720px) {
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
}
.card h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.25;
  margin: 0 0 8px;
}
.card p { margin: 0; }
.card p + p { margin-top: 10px; }
.card.wide { grid-column: 1 / -1; }
.card.private {
  background: var(--brand-softer);
  border-color: var(--brand-soft);
}
.card .more { font-weight: 600; }

.note {
  margin: 28px 0 0;
  font-size: 0.9375rem;
  color: var(--text-2);
  max-width: 46em;
}

.help {
  margin-top: 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 26px 24px;
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.help h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0 0 4px;
}
.help p { margin: 0; color: var(--text-2); }

/* Youtopia Labs' home */

.home { padding-top: 64px; }
.home-intro h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 1.6rem + 4vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}
.home-intro .lead {
  font-size: 1.25rem;
  color: var(--text-2);
  margin: 0 0 48px;
  max-width: 30em;
}
.app-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  max-width: 760px;
  padding: 24px;
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.app-icon { width: 72px; height: 72px; border-radius: 16px; display: block; }
.app-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.625rem;
  line-height: 1.15;
  margin: 2px 0 6px;
}
.app-card h3 a { text-decoration: none; }
.app-card p { margin: 0 0 14px; }
.app-links {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 0.9375rem;
}
@media (max-width: 480px) {
  .app-card { grid-template-columns: minmax(0, 1fr); }
}

/* Not found */

.missing { padding-top: 72px; max-width: 640px; }
.missing h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 1.4rem + 2.6vw, 2.75rem);
  line-height: 1.12;
  margin: 0 0 12px;
}

/* Thai's marks sit above and below the line: its headings need the room. */

:lang(th) :is(h1, h2, h3) { line-height: 1.4; }
:lang(th) .hero h1, :lang(th) .doc-head h1 { line-height: 1.3; }
:lang(th) .eyebrow, :lang(th) .toc-side p { letter-spacing: 0; text-transform: none; font-size: 0.875rem; }
