// PHYSIO SAMOS — Clinic page (Το κέντρο / Ο χώρος μας)
const ClinicHero = () => {
  const { useRef } = React;
  const [t, lang] = useT();
  const headingRef = useRef(null);
  return (
    <section className="page-hero">
      <HeroAurora />
      {/* This is the longest heading on the site — three sentences, 39 characters in Greek
          and French — so it is the one that sets `.page-hero__title`'s 21ch cap. The two
          <br />s that used to force it onto three lines are gone. */}
      <div className="wrap page-hero__inner">
        <span className="eyebrow">{t.clinic.eyebrow}</span>
        <h1 ref={headingRef} className="page-hero__title">
          <window.VariableProximity label={t.clinic.title_a} containerRef={headingRef} {...window.PS.PROX} />{" "}
          <window.VariableProximity label={t.clinic.title_b} containerRef={headingRef} {...window.PS.PROX} />{" "}
          <span className="serif" style={{ color: "var(--sage-dark)" }}>
            <window.VariableProximity label={t.clinic.title_c} containerRef={headingRef} {...window.PS.PROX} />
          </span>
        </h1>
        <p className="page-hero__lead">{t.clinic.lead}</p>
        <div className="page-hero__actions">
          {/* #contact, not #visit: the VisitSection this used to point at was replaced by
              ContactSection, and the anchor went with it — this button had been scrolling
              nowhere. */}
          <a href="#contact" className="btn btn-primary">
            {t.clinic.visit_title}<span className="arrow">→</span>
          </a>
          <a href="tel:+302273078420" className="btn btn-ghost">
            <Icon name="phone" size={14} /> 22730 78420
          </a>
        </div>
      </div>
    </section>
  );
};

const ClinicGallery = () => {
  // The premises end to end: the Pilates studio, the massage room, then the equipment.
  // Each tile owns one palette accent, which is the colour its border lights up on hover —
  // so no two photographs glow the same. See border-glow.jsx and the `.bg-card` block.
  const photos = [
    { src: "pilates-studio-therapist", span: true, pos: "center 45%",    accent: "var(--sage-dark)" },
    { src: "massage-room-empty",                   pos: "center 55%",    accent: "var(--terra)" },
    { src: "normatec-boots",                       pos: "center center", accent: "var(--sage)" },
    { src: "tecar-winback",                        pos: "center 40%",    accent: "var(--terra-dark)" },
    { src: "pilates-balls",                        pos: "center center", accent: "var(--sage-light)" },
  ];
  return (
    <section style={{ paddingTop: 40 }}>
      <div className="wrap-wide">
        <div className="g g--gallery" style={{
          "--cols": "repeat(4, 1fr)",
          gridAutoRows: 220,
          gap: 16,
        }}>
          {photos.map((p) => (
            <window.BorderGlow key={p.src} className="gal-card" style={{
              "--gal-accent": p.accent,
              gridColumn: p.span ? "span 2" : "auto",
              gridRow: p.span ? "span 2" : "auto",
            }}>
              <div className="gal-card__photo">
                <window.Img name={p.src} w={p.span ? 1600 : 800}
                            sizes={p.span ? "(max-width: 900px) 100vw, 46vw" : "(max-width: 900px) 50vw, 23vw"}
                            position={p.pos} alt="" />
              </div>
            </window.BorderGlow>
          ))}
        </div>
      </div>
    </section>
  );
};

const RoomsSection = () => {
  const [t, lang] = useT();
  return (
    <section>
      <div className="wrap">
        <div className="sec-head">
          <span className="eyebrow">{t.clinic.tour_label}</span>
          <h2 className="sec-head__title">
            <window.BlurText text={t.ui.spaces_a} />{" "}
            <span className="serif" style={{ color: "var(--sage-dark)" }}>
              <window.BlurText text={t.ui.spaces_b} />
            </span>
          </h2>
          <p className="sec-head__lead">{t.ui.spaces_lead}</p>
        </div>
        <div className="g g--rule" style={{ "--cols": "repeat(4, 1fr)", gap: 0,
                      borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)" }}>
          {t.clinic.rooms.map((r, i) => (
            <div key={i} style={{
              padding: "40px 28px 40px 0",
              paddingLeft: i > 0 ? 28 : 0,
              borderRight: i < t.clinic.rooms.length - 1 ? "1px solid var(--line)" : "none",
            }}>
              <h3 style={{ fontSize: 24, marginBottom: 14 }}>{r.name}</h3>
              <p style={{ fontSize: 15, color: "var(--ink-3)", lineHeight: 1.55 }}>{r.desc}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
};

const EquipmentSection = () => {
  const [t, lang] = useT();
  return (
    <section style={{ background: "var(--ink)", color: "var(--bg)" }}>
      <div className="wrap">
        {/* `.sec-head` like the rest, but this section is a dark band, so the eyebrow, the
            title and the lead all keep their explicit light colours — `.sec-head__lead`'s
            `--ink-3` would be near-invisible on `--ink`. Same trap as the services process
            block: taking a section's ground away does not take its text colours away. */}
        <div className="sec-head">
          <span className="eyebrow" style={{ color: "var(--sage-light)" }}>{t.clinic.equipment_title}</span>
          <h2 className="sec-head__title" style={{ color: "var(--bg)" }}>
            <window.BlurText text={t.ui.tools_a} />{" "}
            <span className="serif" style={{ color: "var(--sage-light)" }}>
              <window.BlurText text={t.ui.tools_b} />
            </span>
          </h2>
          <p className="sec-head__lead" style={{ color: "rgba(245,241,234,0.7)" }}>{t.clinic.equipment_lead}</p>
        </div>
        <div className="g g--rule" style={{ "--cols": "repeat(4, 1fr)", gap: 0,
                      "--rule": "rgba(245,241,234,0.15)",
                      borderTop: "1px solid rgba(245,241,234,0.15)" }}>
          {t.clinic.equipment.map((e, i) => {
            const lastRow = i >= t.clinic.equipment.length - 4;
            const lastCol = (i + 1) % 4 === 0;
            return (
              <div key={i} style={{
                padding: 28,
                borderBottom: !lastRow ? "1px solid rgba(245,241,234,0.15)" : "none",
                borderRight: !lastCol ? "1px solid rgba(245,241,234,0.15)" : "none",
              }}>
                <div style={{ fontFamily: "var(--font-display)", fontSize: 22, fontWeight: 600, color: "var(--bg)" }}>
                  {e.name}
                </div>
                <p style={{ marginTop: 8, fontSize: 13, color: "rgba(245,241,234,0.7)", lineHeight: 1.55 }}>
                  {e.desc}
                </p>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
};

const MotionSection = () => {
  const [t] = useT();
  const motionOK = window.PS.useMotionOK(700);
  const clips = ["clinic-device", "clinic-massage", "clinic-rehab", "clinic-studio"];
  // Two-tone, like every other section head on the site: roman, then the second half in
  // italic serif at --sage-dark. This one rendered its title as a single run in --ink and was
  // the only head anywhere without the accent — the rooms head directly above it and the
  // contact head below it both carry it, so on one page it read as three headers in two
  // different styles. The split is the sentence's own comma, which every one of the five
  // languages already has, so it needed no new copy — only the same _a/_b key pair
  // `ui.spaces_a`/`spaces_b` uses two sections earlier.
  return (
    <section data-screen-label="In motion">
      <div className="wrap-wide">
        <div className="sec-head">
          <span className="eyebrow">{t.clinic.tour_label}</span>
          <h2 className="sec-head__title">
            <window.BlurText text={t.clinic.motion_title_a} />{" "}
            <span className="serif" style={{ color: "var(--sage-dark)" }}><window.BlurText text={t.clinic.motion_title_b} /></span>
          </h2>
          <p className="sec-head__lead">{t.clinic.motion_lead}</p>
        </div>
        <div className="motion-grid">
          {clips.map((name, i) => (
            <figure key={name} className="motion-cell">
              <div className="motion-frame">
                <img src={`media/${name}-poster.jpg`} alt={t.clinic.motion_items[i]} draggable={false}
                     loading="lazy" decoding="async" />
                {motionOK && (
                  <video className="ps-loop" data-ready="1" aria-hidden="true"
                         autoPlay muted loop playsInline preload="metadata">
                    <source src={`media/${name}.mp4`} type="video/mp4" />
                  </video>
                )}
                {/* Inside the frame, not under it, and in the site's one in-image caption
                    format — `PhotoCaption`, the same accent-bar block the photographs use.
                    It carries no `sub`: every string that could serve as one is already on
                    this page. The room names and their descriptions are the rooms section
                    above, and the three actions ("hands-on work on the reformer, a massage
                    in the treatment room, a session with physical modalities") are the lead
                    directly over these clips. A subtitle here would repeat one of them.
                    `PhotoCaption` renders the title alone when `sub` is absent. */}
                <PhotoCaption title={t.clinic.motion_items[i]} size="sm" />
              </div>
            </figure>
          ))}
        </div>
      </div>
    </section>
  );
};

// ---------- Contact ----------
// Coordinates and the maps link come from window.PS.CLINIC in components.jsx.
const CLINIC = window.PS.CLINIC;

// `fill` marks the card in each column that absorbs the leftover height, so the columns end
// level without the shortest card being the one that stretches.
const ContactCard = ({ icon, accent, label, children, action, fill }) => (
  <div className={`contact-card${fill ? " contact-card--fill" : ""}`} style={{ "--svc": accent }}>
    <span className="contact-card__icon"><Icon name={icon} size={20} /></span>
    <span className="contact-card__label mono">{label}</span>
    <div className="contact-card__body">{children}</div>
    {action ? <div className="contact-card__action">{action}</div> : null}
  </div>
);

const ContactSection = () => {
  const [t] = useT();
  return (
    <section id="contact" data-screen-label="Contact">
      <div className="wrap">
        <div className="sec-head">
          <span className="eyebrow">{t.contact.eyebrow}</span>
          <h2 className="sec-head__title">
            <window.BlurText text={t.contact.title_a} />{" "}
            <span className="serif" style={{ color: "var(--sage-dark)" }}><window.BlurText text={t.contact.title_b} /></span>
          </h2>
          <p className="sec-head__lead">{t.contact.lead}</p>
        </div>

        {/* No inline `--cols` here on purpose: `.contact-grid` owns the ratio so a media
            query can narrow it. See the rule in main.css. */}
        <div className="g g--stack contact-grid" style={{ gap: 24 }}>
          {/* Three grid children, a quarter each for the two card columns and a half for the
              map. `fill` on every card so each column's stack absorbs whatever the tallest
              column leaves over and all three still start and end on one line. */}
          <div className="contact-cards__col">
            <ContactCard icon="phone" accent="#5F9A94" label={t.contact.phone_label} fill
                         action={<a href="tel:+302273078420" className="btn btn-primary btn-sm">{t.ui.dial} →</a>}>
              <a href="tel:+302273078420" className="contact-card__value">{t.contact.phone_value}</a>
            </ContactCard>

            <ContactCard icon="mail" accent="#A9827C" label={t.contact.email_label} fill
                         action={<a href={`mailto:${CLINIC.email}`} className="btn btn-primary btn-sm">
                                   {t.ui.email_cta} →
                                 </a>}>
              <a href={`mailto:${CLINIC.email}`} className="contact-card__value contact-card__value--sm">
                {CLINIC.email}
              </a>
            </ContactCard>
          </div>

          <div className="contact-cards__col">
            <ContactCard icon="clock" accent="#8A9A5B" label={t.contact.hours_label} fill>
              <div className="contact-hours">
                {/* Day above its hours, not beside them — the same label-above-value pair
                    the contact cards and the booking modal's rows already use. Beside them,
                    a split day's two ranges had to stack right-aligned in the leftover
                    width, which read as one time that had wrapped rather than two shifts,
                    and left the four split rows taller than the three single ones.
                    Stacked, every row is the same height and the ranges get the full column.

                    Splitting on our own ", " separator is still what keeps a range whole: an
                    en dash is a valid break opportunity, so a single string broke *inside* a
                    time ("17:00–" / "21:00"). Keep the separator if you edit the hours.

                    `closed` is "this value has no digits in it", which holds in all five
                    languages — Κλειστά / Closed / Geschlossen / Fermé / Kapalı — and every
                    time has digits. It only recesses the value's colour. */}
                {t.contact.hours.map((h, i) => {
                  const parts = h.h.split(", ");
                  const closed = !/\d/.test(h.h);
                  return (
                    <div key={i} className={"contact-hours__row" + (closed ? " is-closed" : "")}>
                      <span className="contact-hours__day">{h.d}</span>
                      <span className="contact-hours__time">
                        {parts.map((part, j) => <span key={j}>{part}</span>)}
                      </span>
                    </div>
                  );
                })}
              </div>
              {/* Sits after the schedule inside `.contact-card__body`, so `.contact-hours`
                  (flex: 1 1 auto) grows and pushes it to the card's foot. The asterisk is in
                  the markup rather than the dictionaries, so the five translations carry the
                  sentence only — and it is aria-hidden because there is no matching marker
                  above for a screen reader to tie it back to. */}
              <p className="contact-hours__note">
                <span aria-hidden="true">*</span>
                <span>{t.contact.hours_note}</span>
              </p>
            </ContactCard>
          </div>

          <div className="contact-side">
            {/* Above the map, not below it: it is a service note, and it wears the same
                full-height icon block as the social tiles. */}
            <div className="contact-note">
              <span className="contact-note__icon"><Icon name="check" size={22} /></span>
              <div className="contact-note__text">
                <div className="contact-note__title">{t.ui.home_visits_title}</div>
                <div className="contact-note__body">{t.ui.home_visits_body}</div>
              </div>
            </div>
            {/* The address card is gone; its two pieces live on the map itself — the address
                at the top, the button at the bottom. A map with the address written on it is
                one object rather than a card describing a picture beside it. */}
            <window.ClinicMap
              label={t.contact.map_btn}
              name={t.brand.name}
              top={
                <>
                  {/* No "ΔΙΕΥΘΥΝΣΗ" eyebrow: the two lines under it are self-evidently an
                      address, and the label was a third register of type in a corner that
                      already carries a street name, a town and a button. */}
                  <div className="clinic-map__addr-block">
                    <span className="clinic-map__addr">{t.contact.address_line1}</span>
                    <span className="clinic-map__sub">
                      {t.contact.address_line2} · {t.contact.address_line3}
                    </span>
                  </div>
                  <a href={CLINIC.maps} target="_blank" rel="noreferrer"
                     className="btn btn-primary btn-sm">
                    {t.contact.map_btn} →
                  </a>
                </>
              } />
            {/* The marks carry their real brand colour, set per tile. */}
            <div className="g g--cards" style={{ "--cols": "1fr 1fr", gap: 12, marginTop: 12 }}>
              <a href="https://www.facebook.com/people/Atzemian-Physio-Samos/100089499093406/"
                 target="_blank" rel="noreferrer" className="contact-social" style={{ "--brand": "#1877F2" }}>
                <span className="contact-social__mark"><Icon name="facebook" size={22} /></span>
                <span className="contact-social__text">
                  <b>Facebook</b><span className="mono">{t.ui.follow} →</span>
                </span>
              </a>
              <a href="https://www.instagram.com/maria_atzemian/" target="_blank" rel="noreferrer"
                 className="contact-social contact-social--ig">
                <span className="contact-social__mark"><Icon name="instagram" size={22} /></span>
                <span className="contact-social__text">
                  <b>Instagram</b><span className="mono">{t.ui.follow} →</span>
                </span>
              </a>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

const App = () => {
  window.PS.useReveal();
  return (
    <>
      <PageBackdrop />
      <Nav current="clinic" />
      <Level at="above"><ClinicHero /><ClinicGallery /><RoomsSection /></Level>
      <Level at="below"><MotionSection /></Level>
      <Level at="above"><ContactSection /></Level>
      <Level at="below"><Footer /></Level>
      <BookingModal />
    </>
  );
};
window.ClinicApp = App;
