/*
 * WatchPaper website. One stylesheet for every page, English (ltr) and Arabic (rtl).
 * Colours are the app's own tokens (src/theme/index.ts): ivory, ink and gold; dark mode uses the app's night tones.
 * Layout uses logical properties (inline/block) so the Arabic pages mirror without extra rules.
 * No text is smaller than 16 px, and every link or button is at least 44 px tall.
 */

/* Arabic fallback: Tajawal (SIL OFL 1.1, assets/fonts/OFL-Tajawal.txt). Only Arabic characters use it, and only when
   the device has no Arabic system font earlier in the stack (Apple and Windows devices never download it). */
@font-face {
  font-family: "WP Tajawal";
  src: url("/assets/fonts/tajawal-400.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: "WP Tajawal";
  src: url("/assets/fonts/tajawal-700.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}

:root {
  color-scheme: light dark;

  --bg: #FBFAF7;
  --surface: #FFFFFF;
  --sunken: #F3F1EC;
  --hairline: #E9E5DD;
  --border: #E1DCD2;
  --ink: #171512;
  --ink-2: #5E5952;
  --gold: #B8862B;
  --gold-text: #7A5A10; /* app goldDeep #8F6614 is 4.3:1 on gold-soft; one step deeper reads 5.4:1 */
  --gold-soft: #F5EBD3;
  --button: #171512;
  --button-ink: #FBFAF7;
  --button-hover: #2E2A25;
  --tile-edge: transparent;
  --focus: #8F6614;

  --font-latin: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-arabic: -apple-system, BlinkMacSystemFont, "SF Arabic", "Geeza Pro", "Segoe UI", "Noto Sans Arabic", "WP Tajawal", Tahoma, sans-serif;

  --gutter: 20px;
  --measure: 44rem;
  --radius: 12px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1116;
    --surface: #151920;
    --sunken: #1B1F27;
    --hairline: #262B35;
    --border: #343A46;
    --ink: #F3F1EC;
    --ink-2: #B3ADA2;
    --gold: #D4AC4E;
    --gold-text: #E2BF6C;
    --gold-soft: #2A2417;
    --button: #F3F1EC;
    --button-ink: #0E1116;
    --button-hover: #DDD8CE;
    --tile-edge: #2C323D;
    --focus: #E2BF6C;
  }
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:lang(ar) {
  font-family: var(--font-arabic);
}

html[lang="ar"] body {
  line-height: 1.85;
}

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

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

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  touch-action: manipulation;
}

:lang(ar) a {
  text-underline-offset: 6px;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  inset-inline-start: 12px;
  top: 12px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip:focus-visible {
  transform: none;
}

/* The page column. The side gutter is symmetric, so physical left/right with the notch insets is safe in both directions. */
.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  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));
}

main {
  flex: 1 0 auto;
}

/* Header */

.site-header {
  padding-top: env(safe-area-inset-top, 0px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 32px;
  height: 32px;
  flex: none;
}

.brand:lang(ar) {
  letter-spacing: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 1rem;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 160ms ease;
}

/* Headings */

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

h1 {
  margin: 0;
  font-size: clamp(2.125rem, 1.6rem + 2.4vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.375rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0 0 6px;
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.4;
}

/* Arabic is never letter-spaced and needs taller lines. */
:lang(ar) h1,
:lang(ar) h2,
:lang(ar) h3 {
  letter-spacing: 0;
  line-height: 1.45;
}

p {
  text-wrap: pretty;
}

/* Home */

.hero {
  padding-block: 32px 48px;
}

.hero-icon {
  display: block;
  width: 88px;
  height: 88px;
  margin-block-end: 24px;
}

.lede {
  max-width: 30ch;
  margin: 14px 0 0;
  color: var(--ink-2);
  font-size: 1.25rem;
  line-height: 1.5;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 24px 0 0;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-text);
  font-size: 1rem;
  font-weight: 600;
}

.section {
  padding-block: 24px 40px;
}

.faces {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.face {
  margin: 0;
}

.face img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 440 / 539;
  border-radius: 22% / 18%;
  background: #000;
  box-shadow: 0 0 0 1px var(--tile-edge);
}

.face figcaption {
  margin-top: 10px;
  font-size: 1rem;
  line-height: 1.4;
}

.face-name {
  display: block;
  font-weight: 600;
}

.face-kind {
  display: block;
  color: var(--ink-2);
}

.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 40px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fact {
  padding-block: 18px 22px;
  border-top: 1px solid var(--hairline);
}

.fact p {
  margin: 0;
  color: var(--ink-2);
}

/* Inner pages */

.page-head {
  padding-block: 32px 8px;
}

.page-head .lede {
  max-width: 40ch;
}

.meta {
  margin: 12px 0 0;
  color: var(--ink-2);
  font-size: 1rem;
}

.summary {
  margin-block: 24px 8px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--sunken);
}

.summary h2 {
  margin-block-end: 8px;
  font-size: 1.0625rem;
}

.summary ul {
  margin: 0;
  padding-inline-start: 1.25em;
}

.summary li + li {
  margin-top: 4px;
}

.prose {
  padding-block-end: 16px;
}

.prose > p,
.prose > ul {
  max-width: 65ch;
}

.prose h2 {
  margin: 40px 0 10px;
  font-size: 1.25rem;
}

.prose p {
  margin: 0 0 14px;
}

.prose ul {
  margin: 0 0 14px;
  padding-inline-start: 1.25em;
}

.prose li + li {
  margin-top: 8px;
}

.prose li::marker {
  color: var(--gold);
}

.path {
  font-weight: 600;
}

/* Support */

.contact {
  margin-block: 28px 8px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.contact h2 {
  margin-block-end: 4px;
  font-size: 1.0625rem;
}

.email {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.email span {
  -webkit-user-select: all;
  user-select: all;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding-inline: 22px;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-ink);
  font-weight: 600;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}

.button:active {
  transform: scale(0.97);
}

.faq {
  margin: 8px 0 0;
  border-top: 1px solid var(--hairline);
}

.faq details {
  border-bottom: 1px solid var(--hairline);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding-block: 14px;
  font-weight: 600;
  line-height: 1.45;
  list-style: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  content: "+" / "";
  flex: none;
  width: 1em;
  color: var(--ink-2);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.faq details[open] > summary::after {
  content: "\2212";
  content: "\2212" / "";
}

.faq .answer {
  padding-block-end: 18px;
  color: var(--ink-2);
}

.faq .answer p {
  margin: 0 0 10px;
  max-width: 65ch;
}

.faq .answer p:last-child {
  margin-block-end: 0;
}

/* 404 */

.notfound {
  padding-block: 48px 24px;
}

.notfound section + section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--hairline);
}

.notfound .title {
  margin: 0;
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
}

.notfound p {
  margin: 12px 0 0;
  color: var(--ink-2);
}

.notfound .home-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  color: var(--ink);
  font-weight: 600;
}

/* Footer */

.site-footer {
  margin-top: 48px;
  padding-block: 28px calc(28px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline);
  color: var(--ink-2);
  font-size: 1rem;
}

.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 24px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.footer-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}

.footer-nav a[aria-current="page"] {
  text-decoration-line: underline;
}

.footer-email a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
}

.site-footer p {
  margin: 0;
}

/* Wider screens */

@media (min-width: 640px) {
  .hero {
    padding-block: 56px 56px;
  }

  .faces {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
  }

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

  .page-head {
    padding-block-start: 48px;
  }
}

/* Press feedback for touch. Colour and opacity only, so it stays under reduced motion. */
.lang-switch:active {
  background: var(--sunken);
}

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

a:not(.button):not(.lang-switch):active,
.faq summary:active {
  opacity: 0.6;
}

/* Hover only where a real pointer can hover, so a tap never leaves a stuck state. */
@media (hover: hover) and (pointer: fine) {
  .button:hover {
    background: var(--button-hover);
  }

  .lang-switch:hover {
    background: var(--sunken);
  }

  .footer-nav a:hover,
  .brand:hover .brand-name {
    text-decoration-line: underline;
    text-decoration-color: var(--gold);
  }

  .faq summary:hover::after {
    color: var(--ink);
  }
}

/* Reduced motion: keep colour changes, drop movement. */
@media (prefers-reduced-motion: reduce) {
  .button {
    transition: background-color 140ms ease;
  }

  .button:active {
    transform: none;
  }
}

@media print {
  .skip,
  .lang-switch,
  .site-footer .footer-nav {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
