/* ============================================================================
   ProChild Hub — Cinematic Design System
   Fonts: Fredoka (display) + Nunito (body) for English; Cairo for Arabic.
   Four brand colors. Sticker motif. Layout uses CSS logical properties so it
   mirrors automatically in RTL (see rtl.css for the few explicit overrides).
   ============================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@400;500;600;700;800&family=Cairo:wght@400;500;600;700;800&display=swap');

/* ---------- Tokens ---------- */
:root {
  --blue:  #346AC5;
  --blue-deep: #2554A8;
  --green: #95BB3A;
  --green-deep: #7DA02E;
  --pink:  #F4BBC9;
  --pink-soft: #FBE4EA;
  --pink-deep: #D6567F; /* deeper rose for filled/active states (blush is too light for contrast) */
  --white: #FFFFFF;
  --ink:   #1F2A44;
  --ink-soft: #5A6785;
  --tint:  #F4F8FF;

  /* English type. Arabic overrides these to Cairo via html[lang="ar"] below. */
  --font-display: 'Fredoka', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;

  /* type scale */
  --fs-xs: 0.875rem;   /* 14 */
  --fs-sm: 1rem;       /* 16 */
  --fs-md: 1.25rem;    /* 20 */
  --fs-lg: 1.75rem;    /* 28 */
  --fs-xl: 2.5rem;     /* 40 */
  --fs-2xl: 3.5rem;    /* 56 */
  --fs-3xl: 4.5rem;    /* 72 */

  --radius: 22px;
  --radius-sm: 14px;
  --radius-pill: 999px;

  --shadow-sm: 0 4px 14px rgba(52,106,197,.10);
  --shadow: 0 8px 24px rgba(52,106,197,.14);
  --shadow-lg: 0 20px 48px rgba(52,106,197,.20);
  --shadow-pink: 0 10px 30px rgba(244,187,201,.45);

  --section-pad: 96px;
  --container: 1180px;
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--blue);
  line-height: 1.1;
  margin: 0 0 .5em;
}

h1 { font-size: clamp(2.25rem, 5vw, var(--fs-3xl)); }
h2 { font-size: clamp(1.75rem, 3.5vw, var(--fs-2xl)); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 1rem; }

a { color: var(--blue); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--green-deep); }

/* Visible keyboard focus for accessibility (mouse clicks don't trigger :focus-visible) */
:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Skip past the reset for screen-reader-only helper */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

img { max-width: 100%; display: block; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

.section { padding-block: clamp(56px, 9vw, var(--section-pad)); }
.section--tint { background: var(--tint); }
.section--pink { background: linear-gradient(180deg, var(--pink-soft), var(--white)); }

.section-head { text-align: center; max-width: 720px; margin: 0 auto clamp(32px, 5vw, 64px); }
.section-head .eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: var(--fs-xs);
  color: var(--green-deep);
  background: rgba(149,187,58,.12);
  padding: .35rem 1rem;
  border-radius: var(--radius-pill);
  margin-bottom: 1rem;
}
.section-head p { color: var(--ink-soft); font-size: var(--fs-md); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  padding: .8rem 1.8rem;
  cursor: pointer;
  transition: transform .18s ease, background-color .2s ease, box-shadow .2s ease, color .2s ease;
  text-decoration: none;
  line-height: 1;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--blue); color: var(--white); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--green); color: var(--white); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--white); color: var(--blue); border-color: var(--blue); }
.btn-ghost:hover { background: var(--blue); color: var(--white); transform: translateY(-2px); }
.btn-green { background: var(--green); color: var(--white); box-shadow: var(--shadow-sm); }
.btn-green:hover { background: var(--green-deep); color: var(--white); transform: translateY(-2px); }
.btn-lg { font-size: var(--fs-md); padding: 1rem 2.4rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards & sticker motif ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

/* peel-able sticker card: white ring + a soft peel-curl in one corner */
.sticker {
  position: relative;
  background: var(--white);
  border: 3px solid var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px rgba(52,106,197,.06);
  padding: 2rem;
  transition: transform .25s ease, box-shadow .25s ease;
}
/* Sticker peel corner — logical inset so it flips to the other corner in RTL (see rtl.css). */
.sticker::after {
  content: "";
  position: absolute;
  bottom: 0; inset-inline-end: 0;
  width: 46px; height: 46px;
  background: linear-gradient(135deg, transparent 46%, rgba(0,0,0,.08) 50%, rgba(255,255,255,.9) 54%);
  border-end-end-radius: var(--radius);
  box-shadow: -3px -3px 8px rgba(0,0,0,.06);
  transition: width .25s ease, height .25s ease;
  pointer-events: none;
}
.sticker:hover::after { width: 64px; height: 64px; }
.sticker__icon {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 16px;
  margin-bottom: 1.1rem;
  color: var(--blue);
}
.sticker__icon--green { background: rgba(149,187,58,.14); color: var(--green-deep); }
.sticker__icon--pink { background: var(--pink-soft); color: var(--blue); }
.sticker__icon--blue { background: rgba(52,106,197,.10); color: var(--blue); }
.sticker h3 { font-size: var(--fs-md); }
.sticker p { color: var(--ink-soft); margin-bottom: 0; }

/* tag/pill */
.tag {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-xs);
  background: var(--pink-soft);
  color: var(--blue);
  border-radius: var(--radius-pill);
  padding: .3rem 1rem;
}

/* ---------- Blob-dash confetti pattern (decorative) ---------- */
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 12% 20%, var(--green) 0 8px, transparent 9px),
    radial-gradient(ellipse 14px 8px at 82% 16%, var(--pink) 0 100%, transparent),
    radial-gradient(circle at 68% 74%, var(--green) 0 7px, transparent 8px),
    radial-gradient(ellipse 16px 9px at 26% 82%, var(--pink) 0 100%, transparent),
    radial-gradient(circle at 92% 60%, var(--pink) 0 6px, transparent 7px),
    radial-gradient(circle at 40% 8%, var(--green) 0 5px, transparent 6px);
  background-repeat: no-repeat;
}

/* ---------- Utilities ---------- */
.grid { display: grid; gap: 1.5rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-0 { margin-bottom: 0; }
.muted { color: var(--ink-soft); }
.relative { position: relative; }
.z1 { position: relative; z-index: 1; }

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Scroll-reveal (JS adds .is-visible) ---------- */
.reveal { opacity: 0; transform: translateY(28px) scale(.98); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.is-visible { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: .08s; }
.reveal[data-delay="2"] { transition-delay: .16s; }
.reveal[data-delay="3"] { transition-delay: .24s; }
.reveal[data-delay="4"] { transition-delay: .32s; }

/* ---------- Image drag/save deterrence (see js/image-guard.js) ----------
   Deters casual dragging/saving of artwork; NOT absolute (anything shown can be captured). */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-select: none;
  user-select: none;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* =====================================================================================
   Custom cursor — a friendly hand on things you can click.

   RULES THIS OBEYS, because breaking any of them makes the site feel broken:
   - ALWAYS a standard fallback after the url(). If the image 404s or the browser refuses it
     (Safari does not accept SVG cursors), `pointer` still applies and nothing is lost.
   - Clickable elements ONLY. Plain page areas keep the arrow.
   - Text inputs and textareas keep the I-beam — replacing it makes typing feel wrong.
   - Nothing on touch (`pointer: coarse`): irrelevant there, and it must not interfere.
   - Nothing in the admin panel (`body:not(.admin-body)`): that is a work tool, not a toy.

   Hotspot "10 2" puts the click point on the fingertip, not the middle of the hand.
   ===================================================================================== */
@media (hover: hover) and (pointer: fine) {
  body:not(.admin-body) :is(
    a[href],
    button:not(:disabled),
    summary,
    label[for],
    [role="button"],
    .btn,
    .theme-tile,
    .gender-pill,
    .pay-method,
    .pch-select__button,
    .pch-select__option,
    .pch-date__button,
    .pch-date__day,
    .pch-date__nav,
    .pch-date__action
  ) {
    cursor: url("/img/cursor/hand.svg") 10 2, pointer;
  }

  /* Never over text entry — the I-beam is information, not decoration. */
  body:not(.admin-body) :is(input:not([type="button"]):not([type="submit"]):not([type="reset"]),
                            textarea, [contenteditable="true"]) {
    cursor: text;
  }
  body:not(.admin-body) :is(input[type="checkbox"], input[type="radio"], input[type="range"]) {
    cursor: url("/img/cursor/hand.svg") 10 2, pointer;
  }
  body:not(.admin-body) :is(a, button, .btn):is(:disabled, [aria-disabled="true"]) {
    cursor: not-allowed;
  }
}

/* =====================================================================================
   §7 — tables become cards on a phone.

   The receipt has seven columns and the admin list seven; both overflowed sideways at phone
   width, so reading one order meant scrolling right. Below 700px each row becomes a card and
   each cell carries its column header as a label (from `data-label`, which reuses the existing
   <th> strings — nothing new to translate).

   SCREEN ONLY. The print block below restores the table, so the printed receipt and the PDF are
   untouched. Above 700px nothing changes at all.
   ===================================================================================== */
@media screen and (max-width: 700px) {
  .stack-table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td { display: block; width: 100%; }

  /* The header row is what supplies the labels, so it is not needed visually — but it must stay
     reachable for screen readers rather than being display:none'd away. */
  .stack-table thead {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }

  .stack-table tr {
    border: 1px solid rgba(52,106,197,.14);
    border-radius: var(--radius-sm);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    padding: .35rem .9rem;
    margin-bottom: .85rem;
  }

  .stack-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    text-align: start !important;      /* overrides the desktop inline text-align:center */
    padding: .5rem 0;
    border: none;
    border-bottom: 1px solid rgba(52,106,197,.08);
  }
  .stack-table tr td:last-child { border-bottom: none; }

  .stack-table td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--fs-xs);
    color: var(--ink-soft);
  }
  /* Cells with no label (the admin row's action button) get the full width instead of a blank gap. */
  .stack-table td:not([data-label])::before { content: none; }
  .stack-table td.cell-action { justify-content: stretch; padding-top: .7rem; }
  .stack-table td.cell-action .btn { width: 100%; justify-content: center; }

  /* The money stays the prominent thing in each card. */
  .stack-table td.cell-total { font-size: var(--fs-md); font-weight: 700; color: var(--blue); }

  /* Nothing may scroll sideways at this width. */
  .table-wrap { overflow-x: visible; }
}

/* The printed receipt and the PDF keep the real table, whatever the screen size. */
@media print {
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: revert; }
  .stack-table thead { position: static; width: auto; height: auto; clip: auto; clip-path: none; }
  .stack-table td::before { content: none; }
}
