/* ==========================================================================
   Room for Hebrew – base styles
   Shared by every page: fonts, design tokens, basic elements, buttons,
   page sections and the scroll animation.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Breakpoints
   Media queries can't read custom properties, so the values are listed here.
   They are written in em so the layout follows the visitor's zoom/text size.
                                                         Content max width
     Mobile  : 320px to 639px  – the base styles, no media query   480px
     Tablet  : 40em (640px) and up                                  832px
     Desktop : 64em (1024px) and up, designed up to 1920px         1168px
   Two layouts are designed (mobile and desktop); tablet scales in between.
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   Fonts (all under the SIL Open Font License; each folder has its OFL.txt)
   -------------------------------------------------------------------------- */

/* Noto Sans 2.015 – body text. One variable file, weights 100 to 900. */
@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/noto-sans/2.015/NotoSans-wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Fraunces – the header title and every heading. From the npm package
   @fontsource-variable/fraunces 5.3.0, Latin letters only. One variable file,
   weights 100 to 900, with optical size. */
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces/5.3.0/fraunces-latin-opsz-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Allura – the word "for" in the header title (a script font). From the npm
   package @fontsource/allura 5.3.0, Latin letters only. */
@font-face {
  font-family: "Allura";
  src: url("../fonts/allura/5.3.0/allura-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Typography */
  --font-body: "Noto Sans", Arial, sans-serif;
  --font-title: "Fraunces", Georgia, serif;       /* header title and all headings */
  --font-title-script: "Allura", cursive;         /* "for" in the title, and one accent word in the hero */

  /* Font sizes. Every text size on the site comes from this list, in rem so
     they follow the visitor's own text size setting (1rem = 16px).
     The big ones grow smoothly with the screen width (clamp). */
  --font-size-hero: clamp(2.25rem, 1.5rem + 3vw, 3.5rem);                 /* hero slogan      36 – 56px */
  --font-size-section-title: clamp(1.75rem, 1.3rem + 1.8vw, 2.5rem);     /* home section titles 28 – 40px */
  --font-size-site-title: 1.125rem;   /* header title                       18 / 24 / 28px */
  --font-size-page-title: 1.375rem;   /* text page titles, course / club titles 22 / 24 / 28px */
  --font-size-lead: 1.125rem;         /* intro sentence under a title      18 / 20px */
  --font-size-card-title: 1.25rem;    /* card titles, menu group titles, popup titles 20px */
  --font-size-body: 1rem;             /* all other text                    16px */
  --font-size-footer-link: 0.9375rem; /* footer links                      15px */
  --font-size-label: 0.8125rem;       /* labels, tags, small notes         13px */
  --font-size-credit: 0.75rem;        /* photo credit on the home page band 12px */

  --line-height-body: 1.5;
  --line-height-title: 1.15;

  /* Palette. Blue is the identity; sun yellow is the one warm accent and is
     used only for call-to-action buttons. */
  --night: #0a1430;   /* hero overlay, footer, text on light backgrounds */
  --navy: #14275a;    /* dark sections, large headings */
  --royal: #2748c7;   /* links, icons, buttons on light backgrounds */
  --sky: #6f9bff;     /* highlights on dark; never carries white text */
  --mist: #e9f0ff;    /* tinted section background */
  --snow: #f6f8ff;    /* soft page background */
  --sun: #ffb81c;     /* call-to-action buttons */
  --sun-hover: #ffc94d;
  --white: #ffffff;

  /* Colours – light theme. Contrast with the page background is noted where
     it matters (all text is at least 4.5:1). */
  --color-bg: #ffffff;
  --color-bg-soft: #f6f8ff;              /* snow sections */
  --color-bg-tint: #e9f0ff;              /* mist sections */
  --color-card: #ffffff;                 /* cards sitting on soft or tinted sections */
  --color-text: #0a1430;                 /* 18:1 */
  --color-text-muted: #44506f;           /* 7:1 on the tint */
  --color-heading: #14275a;              /* 12.5:1 on the tint */
  --color-accent: #2748c7;               /* icons, outlines, links  6.5:1 on the tint */
  --color-surface: #f6f8ff;              /* soft panels on white pages */
  --color-border: #d3def7;               /* thin decorative borders */
  --color-focus: #14275a;                /* keyboard focus outline */
  --color-on-dark-muted: #c5d1f0;        /* quiet text on night and navy, 9.4:1 or better */
  --focus-on-dark: #ffffff;
  --error-on-dark: #ff9a9a;              /* required marks and error messages on navy, 7:1 */
  --success-on-dark: #8fe3a6;            /* the "sent" messages on navy, 9:1 */

  /* Strong fill (discount labels, selected filter chips) */
  --fill-strong: linear-gradient(135deg, #2748c7, #14275a);
  --fill-strong-hover: linear-gradient(135deg, #3a5fd9, #1c3578);
  --color-on-strong: #ffffff;

  --shadow-raised: 0 0.25rem 0.75rem rgb(20 39 90 / 0.14);
  --shadow-card: 0 0.5rem 1.5rem rgb(20 39 90 / 0.1);
  --shadow-lift: 0 1rem 2rem rgb(20 39 90 / 0.16);

  /* Thin line around a part of the page */
  --divider-width: 1px;

  /* Corner radii */
  --radius-card: 1.25rem;
  --radius-control: 0.5rem;
  --radius-pill: 999px;

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-s: 0.75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Horizontal space between the screen edge and the content */
  --page-gutter: var(--space-m);

  /* The content never grows wider than this; on wider screens it is centred.
     Backgrounds (header, sections, footer) still fill the whole width. */
  --content-max-width: 30rem;

  /* Side padding for full-width parts: at least the gutter, and more when
     needed to keep the content within --content-max-width. 100% is the width
     of the part it is used in. */
  --page-inline-padding: max(
    var(--page-gutter),
    (100% - var(--content-max-width)) / 2
  );

  /* Motion */
  --duration-base: 250ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Height of the sticky header (see css/header.css) */
  --header-height: 4rem;
}

/* Theme chosen with the footer switch (js/theme.js). It overrides the device
   setting, and also sets the browser's own parts (e.g. scrollbars) to match. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Colours – dark theme: used when the device is set to dark and no light
   theme was chosen, or when the dark theme was chosen with the switch.
   The dark hero, contact section and footer look the same in both themes. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0c1224;
    --color-bg-soft: #101a36;
    --color-bg-tint: #14224a;
    --color-card: #172a56;
    --color-text: #eef3ff;               /* 12.6:1 on a card */
    --color-text-muted: #a9b6dc;         /*  6.9:1 on a card */
    --color-heading: #ffffff;
    --color-accent: #8fb0ff;             /*  6.5:1 on a card */
    --color-surface: #101a36;
    --color-border: #2c3f75;
    --color-focus: #c9d8fb;

    --fill-strong: linear-gradient(135deg, #e9f0ff, #6f9bff);
    --fill-strong-hover: linear-gradient(135deg, #f6f8ff, #9db9ff);
    --color-on-strong: #0a1430;

    --shadow-raised: 0 0.25rem 0.75rem rgb(0 0 0 / 0.5);
    --shadow-card: 0 0.5rem 1.5rem rgb(0 0 0 / 0.4);
    --shadow-lift: 0 1rem 2rem rgb(0 0 0 / 0.55);
  }
}

/* The same dark colours, when chosen with the switch.
   Keep identical to the block above. */
:root[data-theme="dark"] {
  --color-bg: #0c1224;
  --color-bg-soft: #101a36;
  --color-bg-tint: #14224a;
  --color-card: #172a56;
  --color-text: #eef3ff;
  --color-text-muted: #a9b6dc;
  --color-heading: #ffffff;
  --color-accent: #8fb0ff;
  --color-surface: #101a36;
  --color-border: #2c3f75;
  --color-focus: #c9d8fb;
  --fill-strong: linear-gradient(135deg, #e9f0ff, #6f9bff);
  --fill-strong-hover: linear-gradient(135deg, #f6f8ff, #9db9ff);
  --color-on-strong: #0a1430;
  --shadow-raised: 0 0.25rem 0.75rem rgb(0 0 0 / 0.5);
  --shadow-card: 0 0.5rem 1.5rem rgb(0 0 0 / 0.4);
  --shadow-lift: 0 1rem 2rem rgb(0 0 0 / 0.55);
}

/* Tablet */
@media (min-width: 40em) {
  :root {
    --page-gutter: var(--space-xl);
    --content-max-width: 52rem;
    --font-size-site-title: 1.5rem;
    --font-size-page-title: 1.5rem;
    --font-size-lead: 1.25rem;
    --header-height: 4.5rem;
  }
}

/* Desktop */
@media (min-width: 64em) {
  :root {
    --content-max-width: 73rem;
    --font-size-site-title: 1.75rem;
    --font-size-page-title: 1.75rem;
  }
}

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

html {
  /* Anchor links stop below the sticky header */
  scroll-padding-top: calc(var(--header-height) + var(--space-m));
}

/* Anchor links glide instead of jumping, unless the visitor asked for less motion */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-bg);
}

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

img {
  height: auto;
}

/* No default outer spacing on text elements: spacing always comes from the
   layout around them (gap/padding), so every gap is set in one place. */
h1,
h2,
h3,
p,
ul,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-title);
  font-weight: 700;
  line-height: var(--line-height-title);
  color: var(--color-heading);
  text-wrap: balance;
}

/* Page titles: the text page titles (h1) and the course / club titles */
h1,
h2 {
  font-size: var(--font-size-page-title);
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* A clearly visible keyboard focus indicator, in both themes */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* On the dark parts (header, hero, contact section, footer) the ring is white */
.on-dark :focus-visible {
  outline-color: var(--focus-on-dark);
}

/* Icons come from images/icons.svg (Tabler Icons, outline style). They take
   the colour of the text around them. */
.icon {
  flex-shrink: 0;
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Page layout
   -------------------------------------------------------------------------- */
/* Header, main content and footer stacked. Main takes up any spare height,
   so on short pages the footer still sits at the bottom of the window. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Text pages: sections stacked with --space-xl between them. The home page
   overrides this: its sections run edge to edge (css/home.css). */
main {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: var(--space-xl);
  padding: var(--space-xl) var(--page-inline-padding);
}

/* --------------------------------------------------------------------------
   Buttons
   Primary (sun yellow) is the call to action: WhatsApp and call. Use it once
   or twice per screen. Secondary buttons are outlined.
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 2.75rem;
  padding: 0.5rem 1.5rem;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: var(--color-text);
  background: none;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.btn--primary {
  color: var(--night);
  background-color: var(--sun);
  box-shadow: 0 0.375rem 1.125rem rgb(255 184 28 / 0.3);
}

/* Outlined, for light backgrounds */
.btn--outline {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* Outlined, for dark backgrounds */
.btn--ghost {
  color: var(--white);
  border-color: rgb(255 255 255 / 0.75);
}

@media (hover: hover) {
  .btn--primary:hover {
    background-color: var(--sun-hover);
  }

  .btn--outline:hover {
    color: var(--color-bg);
    background-color: var(--color-accent);
  }

  .btn--ghost:hover {
    color: var(--night);
    background-color: var(--white);
  }
}

/* --------------------------------------------------------------------------
   Page sections (home page). Each one fills the full width with its own
   background; its content stays within the content width.
   -------------------------------------------------------------------------- */
.section {
  padding: clamp(3.5rem, 2rem + 5vw, 6.5rem) var(--page-inline-padding);
  background-color: var(--color-bg);
}

.section--snow {
  background-color: var(--color-bg-soft);
}

.section--mist {
  background-color: var(--color-bg-tint);
}

/* Dark section, the same in both themes */
.section--navy {
  color: var(--white);
  background-color: var(--navy);
}

.section--navy h2,
.section--navy h3 {
  color: var(--white);
}

.section__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-s);
  max-width: 42rem;
  margin: 0 auto var(--space-2xl);
  text-align: center;
}

.section__title {
  font-size: var(--font-size-section-title);
  font-weight: 800;
}

.section__lead {
  font-size: var(--font-size-lead);
  color: var(--color-text-muted);
}

/* Small label above a section title */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--font-size-label);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

/* "Skip to main content": hidden until it receives keyboard focus */
.skip-link {
  position: fixed;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: 60; /* above the sticky header */
  padding: var(--space-xs) var(--space-m);
  color: var(--night);
  background-color: var(--sun);
  font-weight: 700;
}

.skip-link:not(:focus) {
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

/* Text that screen readers announce but is not shown on screen */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Keeps short text, like a phone number, on one line */
.nowrap {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Scroll animation (js/reveal.js)
   Parts marked .reveal fade and slide up when they scroll into view. The
   script adds .reveal-on to <html> only when the visitor hasn't asked for
   less motion, so with reduced motion, or without JavaScript, everything is
   simply visible.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal-on .reveal {
    opacity: 0;
    transform: translateY(1.75rem);
    transition:
      opacity 700ms var(--ease-out),
      transform 700ms var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
  }

  .reveal-on .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Shared by the home and course pages: the "?" button and popups
   -------------------------------------------------------------------------- */
/* Round "?" button that opens a popup (e.g. next to "Level:"). The button
   is bigger than its icon, so it is easier to tap. */
.info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25em;
  vertical-align: middle;
  color: var(--color-accent);
  background-color: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

@media (hover: hover) {
  .info-button:hover {
    background-color: var(--color-border);
  }
}

.info-button svg {
  width: 1.5em;
  height: 1.5em;
}

/* --------------------------------------------------------------------------
   Popups (built-in browser popovers, see the home page and the course pages)
   Centred on the screen, with a close button in the top-right corner. The
   page behind stays usable; a shadow and a blue accent line along the top
   set the popup apart from it.
   -------------------------------------------------------------------------- */
.popup {
  width: min(30rem, 100% - 2 * var(--page-gutter));
  max-height: calc(100% - 2 * var(--page-gutter));
  padding: var(--space-m);
  color: var(--color-text);
  background-color: var(--color-bg);
  border: var(--divider-width) solid var(--color-border);
  border-top: 0.25rem solid var(--color-accent);
  border-radius: 1rem;
  box-shadow: 0 0.5rem 1.5rem color-mix(in srgb, var(--night) 30%, transparent);
}

/* Open popup: title and text stacked */
.popup:popover-open {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* A popup marked data-anchored opens beside the button that opened it:
   js/popup-anchor.js measures it and sets --anchor-left and --anchor-top.
   Without the script it stays in the middle of the screen. */
.popup.is-anchored {
  inset: auto;
  top: var(--anchor-top);
  left: var(--anchor-left);
  margin: 0;
}

/* Hidden until js/popup-anchor.js has measured it and set its place, so it
   never shows in the wrong place first */
.popup.is-anchored:not(.is-placed) {
  visibility: hidden;
}

.popup__close {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  color: var(--color-accent);
  background-color: transparent;
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
}

@media (hover: hover) {
  .popup__close:hover {
    background-color: var(--color-surface);
  }
}

.popup__close svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Leaves room for the close button on the title's right */
.popup__title {
  padding-right: 2.75rem;
  font-size: var(--font-size-card-title);
}
