/* ==========================================================================
   Hafelah — public site design system
   Palette, type and spacing tokens live here; every component below
   derives from them. Arabic (RTL) is the default direction, English (LTR)
   is toggled at runtime — layout uses logical properties so both work.
   ========================================================================== */

:root {
    /* Color — from the brand logo navy and the product's world:
       bus amber, map-route teal, "arrived safe" green, morning-sky background */
    --ink: #123A56;
    --night: #0B2334;
    --day: #F4F8FB;
    --card: #FFFFFF;
    --amber: #FFB400;
    --amber-deep: #E09E00;
    --route: #17877B;
    --safe: #27A05D;
    --muted: #557086;
    --line: #D9E4EC;
    --on-night: #EAF2F8;
    --on-night-muted: #9FB6C6;

    /* Type */
    --font-display: "Rubik", "IBM Plex Sans Arabic", system-ui, sans-serif;
    --font-body: "IBM Plex Sans Arabic", "Rubik", system-ui, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;

    --fs-hero: clamp(2rem, 4.6vw, 3.4rem);
    --fs-h2: clamp(1.5rem, 2.8vw, 2.15rem);
    --fs-h3: 1.16rem;
    --fs-body: 1.02rem;
    --fs-small: 0.87rem;

    /* Layout */
    --container: 1120px;
    --radius: 14px;
    --radius-lg: 22px;
    --shadow: 0 10px 30px rgba(11, 35, 52, 0.10);
    --shadow-soft: 0 4px 14px rgba(11, 35, 52, 0.07);
    --section-y: clamp(3.5rem, 8vw, 6rem);
}

/* Base ------------------------------------------------------------------- */

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

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: 1.75;
    color: var(--ink);
    background: var(--day);
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
    font-family: var(--font-display);
    line-height: 1.3;
    margin: 0 0 0.6em;
    color: var(--ink);
}

p { margin: 0 0 1em; }

a { color: var(--route); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.container {
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
}

/* Buttons ---------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.72rem 1.6rem;
    border-radius: 999px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }

.btn-amber {
    background: var(--amber);
    color: var(--night);
    box-shadow: 0 6px 18px rgba(255, 180, 0, 0.35);
}
.btn-amber:hover { background: var(--amber-deep); }

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--ink); }

.btn-ghost-light {
    background: transparent;
    color: var(--on-night);
    border-color: rgba(234, 242, 248, 0.4);
}
.btn-ghost-light:hover { border-color: var(--on-night); }

/* Header ----------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(244, 248, 251, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-height: 72px;
}

.brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand img { height: 46px; width: auto; }

.main-nav { display: flex; gap: 1.4rem; margin-inline-start: auto; }
.main-nav a {
    color: var(--ink);
    font-weight: 500;
    font-size: 0.98rem;
    padding-block: 0.35rem;
}
.main-nav a:hover { color: var(--route); text-decoration: none; }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

.lang-toggle {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    cursor: pointer;
}
.lang-toggle:hover { border-color: var(--route); color: var(--route); }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    color: var(--ink);
}

/* Hero ------------------------------------------------------------------- */

.hero { padding-block: var(--section-y); overflow: hidden; }

.hero .container {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--fs-small);
    color: var(--route);
    background: rgba(23, 135, 123, 0.10);
    border-radius: 999px;
    padding: 0.35rem 1rem;
    margin-bottom: 1.2rem;
}

.hero h1 {
    font-size: var(--fs-hero);
    font-weight: 700;
    margin-bottom: 0.55em;
}
.hero h1 .accent { color: var(--amber-deep); }

.hero .lead {
    font-size: 1.13rem;
    color: var(--muted);
    max-width: 34em;
    margin-bottom: 1.8rem;
}

.hero-ctas { display: flex; flex-wrap: wrap; gap: 0.9rem; }

/* Live tracking card — the page signature -------------------------------- */

.track-card {
    background: linear-gradient(160deg, #10334E 0%, var(--night) 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.4rem;
    color: var(--on-night);
    /* 430px map area + card padding, so the map's px coordinate space
       (SVG viewBox, offset-path, pin positions) lines up 1:1 */
    max-width: 478px;
    margin-inline: auto;
    width: 100%;
}

.track-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.track-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.track-sub { color: var(--on-night-muted); font-size: var(--fs-small); }

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #FF8989;
    background: rgba(255, 107, 107, 0.12);
    border-radius: 999px;
    padding: 0.22rem 0.7rem;
}
.live-badge::before {
    content: "";
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #FF6B6B;
    animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.75); }
}

.track-map {
    position: relative;
    background:
        linear-gradient(rgba(234, 242, 248, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(234, 242, 248, 0.05) 1px, transparent 1px),
        #0E2B41;
    background-size: 28px 28px, 28px 28px, auto;
    border-radius: var(--radius);
    height: 210px;
    overflow: hidden;
    direction: ltr; /* map geometry is the same in both languages */
}

.track-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.bus-dot {
    position: absolute;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--amber);
    display: grid;
    place-items: center;
    color: var(--night);
    box-shadow: 0 0 0 6px rgba(255, 180, 0, 0.22);
    offset-path: path("M 30 170 C 110 150, 120 60, 205 65 C 280 70, 300 140, 375 120");
    animation: ride 9s ease-in-out infinite;
}
@keyframes ride {
    0% { offset-distance: 0%; }
    46% { offset-distance: 100%; }
    54% { offset-distance: 100%; }
    100% { offset-distance: 0%; }
}

.map-pin {
    position: absolute;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 3px solid var(--on-night);
    transform: translate(-50%, -50%);
}
.pin-home { left: 30px; top: 170px; background: var(--route); }
.pin-school { left: 375px; top: 120px; background: var(--safe); }

.track-toasts { position: relative; height: 64px; margin-top: 1rem; }

.toast {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: rgba(234, 242, 248, 0.07);
    border: 1px solid rgba(234, 242, 248, 0.12);
    border-radius: var(--radius);
    padding: 0.65rem 0.9rem;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}
/* Incoming toast waits for the outgoing one to finish fading */
.toast.on { opacity: 1; transition-delay: 0.4s; }

.toast-icon {
    flex: none;
    width: 34px; height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1rem;
}
.toast-icon.i-board { background: rgba(255, 180, 0, 0.18); color: var(--amber); }
.toast-icon.i-route { background: rgba(23, 135, 123, 0.22); color: #52C9BC; }
.toast-icon.i-safe { background: rgba(39, 160, 93, 0.2); color: #5ED393; }

.toast-text { font-size: 0.92rem; line-height: 1.4; }
.toast-text small { display: block; color: var(--on-night-muted); font-size: 0.76rem; }

.eta-chip {
    margin-inline-start: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--amber);
    background: rgba(255, 180, 0, 0.12);
    border-radius: 8px;
    padding: 0.25rem 0.6rem;
    white-space: nowrap;
}

/* Trust strip ------------------------------------------------------------ */

.trust { border-block: 1px solid var(--line); background: var(--card); }
.trust .container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(1.2rem, 4vw, 3.5rem);
    padding-block: 1.1rem;
}
.trust-item {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--muted);
}
.trust-item svg { color: var(--route); flex: none; }

/* Section scaffolding ----------------------------------------------------- */

.section { padding-block: var(--section-y); }
.section-alt { background: var(--card); }

.section-head { max-width: 640px; margin-bottom: clamp(2rem, 5vw, 3.4rem); }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head h2 { font-size: var(--fs-h2); font-weight: 700; }
.section-head p { color: var(--muted); margin: 0; }

/* Journey timeline — the route, stop by stop ------------------------------ */

.journey-line {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}
.journey-line::before {
    content: "";
    position: absolute;
    inset-inline: 2.6rem;
    top: 27px;
    border-top: 3px dashed var(--line);
}

.stop { position: relative; text-align: center; padding-inline: 0.4rem; }

.stop-marker {
    position: relative;
    z-index: 1;
    width: 54px; height: 54px;
    margin: 0 auto 1.1rem;
    border-radius: 50%;
    background: var(--card);
    border: 3px solid var(--route);
    display: grid;
    place-items: center;
    color: var(--route);
    box-shadow: var(--shadow-soft);
}
.stop:last-child .stop-marker { border-color: var(--safe); color: var(--safe); }

.stop h3 { font-size: var(--fs-h3); font-weight: 600; margin-bottom: 0.35em; }
.stop p { color: var(--muted); font-size: 0.94rem; margin: 0; }

/* Features grid ----------------------------------------------------------- */

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.4rem;
}

.feature {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.6rem 1.5rem;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.feature-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    background: rgba(23, 135, 123, 0.10);
    color: var(--route);
    display: grid;
    place-items: center;
    margin-bottom: 1rem;
}
.feature:nth-child(3n+2) .feature-icon { background: rgba(255, 180, 0, 0.14); color: var(--amber-deep); }
.feature:nth-child(3n) .feature-icon { background: rgba(39, 160, 93, 0.12); color: var(--safe); }

.feature h3 { font-size: var(--fs-h3); font-weight: 600; margin-bottom: 0.4em; }
.feature p { color: var(--muted); font-size: 0.95rem; margin: 0; }

/* Platforms --------------------------------------------------------------- */

.platforms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.4rem;
}

.platform {
    border-radius: var(--radius-lg);
    padding: 1.9rem 1.7rem;
    background: var(--card);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}
.platform-feature { background: var(--night); border-color: var(--night); color: var(--on-night); }
.platform-feature h3 { color: var(--on-night); }
.platform-feature .platform-tag { background: rgba(255, 180, 0, 0.15); color: var(--amber); }
.platform-feature li { color: var(--on-night-muted); }
.platform-feature li::before { color: var(--amber); }

.platform-tag {
    align-self: flex-start;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--route);
    background: rgba(23, 135, 123, 0.10);
    padding: 0.25rem 0.8rem;
    border-radius: 999px;
    margin-bottom: 1rem;
}

.platform h3 { font-size: 1.3rem; font-weight: 700; }
.platform ul { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.platform li {
    position: relative;
    padding-inline-start: 1.5rem;
    margin-bottom: 0.55rem;
    color: var(--muted);
    font-size: 0.95rem;
}
.platform li::before {
    content: "✓";
    position: absolute;
    inset-inline-start: 0;
    color: var(--safe);
    font-weight: 700;
}

/* CTA band ---------------------------------------------------------------- */

.cta-band {
    background: linear-gradient(150deg, #10334E 0%, var(--night) 90%);
    color: var(--on-night);
    padding-block: var(--section-y);
}
.cta-band .container { text-align: center; max-width: 760px; }
.cta-band h2 { color: var(--on-night); font-size: var(--fs-h2); font-weight: 700; }
.cta-band p { color: var(--on-night-muted); margin-bottom: 2rem; }
.cta-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.9rem; }

/* Footer ------------------------------------------------------------------ */

.site-footer { background: var(--night); color: var(--on-night-muted); }

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 2.5rem;
    padding-block: 3.2rem;
}

.footer-brand img {
    height: 52px;
    background: var(--card);
    border-radius: 12px;
    padding: 6px 10px;
    margin-bottom: 1rem;
}
.footer-brand p { font-size: 0.93rem; max-width: 30em; }

.site-footer h4 {
    color: var(--on-night);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.6rem; font-size: 0.93rem; }
.site-footer a { color: var(--on-night-muted); }
.site-footer a:hover { color: var(--amber); text-decoration: none; }

.footer-bottom {
    border-top: 1px solid rgba(234, 242, 248, 0.12);
    padding-block: 1.2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.85rem;
}

/* Contact page ------------------------------------------------------------- */

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: start;
}

.contact-page h1 { font-size: var(--fs-h2); font-weight: 700; }
.contact-page .lead { color: var(--muted); }

.contact-list { list-style: none; margin: 1.8rem 0 0; padding: 0; }
.contact-list li {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
    color: var(--muted);
}
.contact-list svg { color: var(--route); flex: none; }

.contact-form {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: clamp(1.4rem, 3vw, 2.2rem);
}

.field { margin-bottom: 1.1rem; }
.field label {
    display: block;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 0.35rem;
}
.field label small { color: var(--muted); font-weight: 400; }

.field input,
.field textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.98rem;
    color: var(--ink);
    background: var(--day);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 0.65rem 0.9rem;
    transition: border-color 0.15s ease;
}
.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--route);
    box-shadow: 0 0 0 3px rgba(23, 135, 123, 0.15);
}
.field textarea { resize: vertical; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.field-error { display: block; color: #C0392B; font-size: 0.82rem; margin-top: 0.25rem; }

.form-success {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(39, 160, 93, 0.10);
    border: 1px solid rgba(39, 160, 93, 0.35);
    color: var(--safe);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.2rem;
    font-weight: 500;
}
.form-success svg { flex: none; }

/* Honeypot field — visually gone, still in the DOM for bots */
.hp-field {
    position: absolute;
    inset-inline-start: -9999px;
    width: 1px; height: 1px;
    overflow: hidden;
}

@media (max-width: 960px) {
    .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .field-row { grid-template-columns: 1fr; gap: 0; }
}

/* Legal pages (privacy) ---------------------------------------------------- */

.legal { padding-block: var(--section-y); }
.legal .container { max-width: 780px; }
.legal h1 { font-size: var(--fs-h2); }
.legal h2 { font-size: 1.25rem; margin-top: 2rem; }
.legal p, .legal li { color: var(--muted); }

/* Reveal on scroll --------------------------------------------------------- */

.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.in { opacity: 1; transform: none; }

/* Reduced motion ----------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .bus-dot, .live-badge::before { animation: none; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .btn, .feature { transition: none; }
}

/* Responsive --------------------------------------------------------------- */

@media (max-width: 960px) {
    .hero .container { grid-template-columns: 1fr; }
    .track-card { margin-inline: 0; }
    .features-grid, .platforms-grid { grid-template-columns: repeat(2, 1fr); }
    .journey-line { grid-template-columns: repeat(2, 1fr); row-gap: 2.2rem; }
    .journey-line::before { display: none; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .main-nav {
        display: none;
        position: absolute;
        top: 72px;
        inset-inline: 0;
        flex-direction: column;
        gap: 0;
        background: var(--card);
        border-bottom: 1px solid var(--line);
        padding: 0.6rem 1.4rem 1rem;
    }
    .main-nav.open { display: flex; }
    .main-nav a { padding-block: 0.7rem; border-bottom: 1px solid var(--line); }
    .main-nav a:last-child { border-bottom: none; }
    .nav-toggle { display: block; }
    .header-cta { display: none; }

    .features-grid, .platforms-grid, .journey-line { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 1.8rem; }
    .track-card { padding: 1.1rem; }
}
