/* Spasiklas — mobile / responsive overrides.
   Loaded after _shared.css. Uses !important where it has to compete with inline grid templates. */

/* ---------- Pancyprian countdown strip ---------- */
/* Sits above the sign-in strip. Auto-hidden by JS after first exam day. */
.spas-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  /* Light blue palette sampled from the cyan circle inside the Spasiklas logo */
  background: linear-gradient(90deg, #e0f7fa 0%, #b2ebf2 100%);
  color: #006064;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid #4dd0e1;
  text-align: center;
}
.spas-countdown:hover { background: linear-gradient(90deg, #b2ebf2 0%, #80deea 100%); }
.spas-countdown .cd-flag {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  margin-right: 2px;
}
.spas-countdown .cd-flag svg {
  width: 17px;
  height: 17px;
  display: block;
  color: var(--cm-cyan-700);
}
.spas-countdown .cd-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.spas-countdown .cd-prefix { font-weight: 600; }
.spas-countdown .cd-vals {
  font-family: var(--cm-mono);
  font-weight: 800;
  color: #00838f;
  letter-spacing: 0.02em;
}
.spas-countdown .cd-ls {
  font-size: 10px;
  margin-right: 4px;
  margin-left: 1px;
  color: #0097a7;
  font-weight: 600;
}
.spas-countdown .cd-suffix {
  color: #00838f;
  font-weight: 500;
  font-size: 12px;
}
@media (max-width: 720px) {
  .spas-countdown { font-size: 12px; padding: 6px 12px; }
  .spas-countdown .cd-suffix { display: none; }
}
@media (max-width: 480px) {
  .spas-countdown .cd-flag { display: none; }
}

/* ---------- Sign-in strip (under header, every page) ----------
   Hidden by default — JS reveals it only when the user is confirmed
   anonymous. Prevents a flash for signed-in users (most return visits). */
.spas-strip {
  display: none;
  background: var(--cm-navy-700);
  color: rgba(255,255,255,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  line-height: 1.4;
}
.spas-strip.is-visible { display: block; }
.spas-strip .cm-container {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 7px;
  padding-bottom: 7px;
}
.spas-strip-msg { flex: 1; min-width: 0; }
.spas-strip-msg .spas-strip-sub { color: rgba(255,255,255,0.65); margin-left: 6px; }
.spas-strip strong { color: #fff; font-weight: 700; }
.spas-strip-cta {
  flex-shrink: 0;
  background: var(--cm-accent-600);
  color: #fff;
  padding: 5px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms;
}
.spas-strip-cta:hover { background: var(--cm-accent-700); color: #fff; }

/* Tablet: hide the sub-line, keep main message */
@media (max-width: 880px) {
  .spas-strip-msg .spas-strip-sub { display: none; }
}
/* Mobile: keep just the CTA pill + a 3-word teaser */
@media (max-width: 720px) {
  .spas-strip { font-size: 12px; }
  .spas-strip .cm-container { padding-top: 6px; padding-bottom: 6px; gap: 10px; }
  .spas-strip-msg {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255,255,255,0.75);
  }
  .spas-strip-msg strong { color: #fff; }
  .spas-strip-cta { padding: 4px 11px; font-size: 11px; }
}
/* Tiny phones: strip vanishes entirely — header tap target stays primary */
@media (max-width: 380px) {
  .spas-strip { display: none; }
}



/* ---------- Nav toggle hidden too: minimal header (logo only).
     Nav links are kept in the DOM but hidden so we can flip them back on
     later by removing these rules. */
.cm-header nav,
.nav-toggle { display: none !important; }
.cm-header { position: relative; overflow: visible !important; }
.cm-header .inner { gap: 12px; overflow: visible !important; }
.cm-header .right { margin-left: auto; }

/* ---------- Brand: big square mascot.
   Note: _shared.css has a `.cm-header .brand img { height: 28px }` rule
   from the Cyprusmetrics inheritance — we override with higher specificity. */
.cm-header .brand.brand-big {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-bottom: 0;     /* removed reserved space — live pill is now in the right block */
}
.cm-header .brand.brand-big .brand-logo-wrap {
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  line-height: 0;
}
.cm-header .brand.brand-big img.brand-logo {
  display: block;
  width: 38px !important;
  height: 38px !important;
  max-height: 38px !important;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.10));
  transition: transform 200ms ease;
}
.cm-header .brand.brand-big:hover img.brand-logo { transform: rotate(-4deg) scale(1.04); }
.brand-word { display: inline-flex; align-items: baseline; gap: 6px; }
.brand-name {
  font-family: var(--cm-sans);
  font-weight: 800;
  font-size: 22px;
  color: var(--cm-navy-700);
  letter-spacing: -0.01em;
}
.brand-tag {
  font-family: var(--cm-mono);
  font-size: 10px;
  color: var(--cm-accent-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* ---------- Live presence: replaces the right-side "Σύνδεση" pill ----------
   IMPORTANT: the inline-flex rule must NOT win over [hidden] — use :not() to
   exclude hidden elements explicitly. Otherwise both states show at once. */
.cm-login .login-anon:not([hidden]),
.cm-login .login-live:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cm-login [hidden] { display: none !important; }

/* Round logout button — appears next to the live pill when signed in */
.cm-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  color: var(--cm-ink-soft);
  border: 1px solid var(--cm-rule);
  text-decoration: none;
  transition: background 120ms, color 120ms, border-color 120ms, transform 80ms;
  flex-shrink: 0;
}
.cm-logout[hidden] { display: none !important; }
.cm-logout svg { width: 14px; height: 14px; display: block; }
.cm-logout:hover {
  background: var(--cm-down-bg);
  color: var(--cm-down);
  border-color: var(--cm-down);
}
.cm-logout:active { transform: scale(0.92); }
@media (max-width: 720px) {
  .cm-logout { width: 26px; height: 26px; }
  .cm-logout svg { width: 12px; height: 12px; }

  /* Signed-in pill collapses to a compact dot-only indicator on mobile.
     Tapping the dot still navigates to /account where the user can logout. */
  .cm-login.signed-in {
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    justify-content: center;
    border-width: 2px;
  }
  .cm-login .login-live .live-name,
  .cm-login .login-live .live-lbl { display: none !important; }
  .cm-login .login-live .live-dot { margin: 0; }

  /* Anonymous "Σύνδεση" still shows but text shrinks */
  .cm-login .login-anon span:last-child { display: none; }

  /* BETA tag — hidden on mobile. Even the 9px pill version + CY/GR flags +
     share icon + avatar + EL/EN switcher cumulatively push the language
     switcher off the right edge. The site is still in beta but mobile
     visitors don't need that label cluttering the header. Desktop keeps it. */
  .brand-tag {
    display: none !important;
  }
}
@media (max-width: 380px) {
  /* Extra-tight: hide logout icon (logout still available from /account) */
  .cm-logout { display: none !important; }
}
.cm-login.signed-in {
  border-color: var(--cm-up);
  color: var(--cm-up);
  background: #fff;
  box-shadow: 0 2px 6px -2px rgba(31, 122, 62, 0.25);
  animation: live-pop 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cm-login.signed-in:hover {
  border-color: var(--cm-up);
  color: var(--cm-up);
  box-shadow: 0 0 0 3px rgba(31, 122, 62, 0.15);
}
.cm-login.signed-in::before { background: var(--cm-up); }   /* small accent dot */
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cm-up);
  box-shadow: 0 0 0 0 rgba(31, 122, 62, 0.55);
  animation: live-pulse 1.5s infinite;
  flex-shrink: 0;
}
.live-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cm-up);
  font-weight: 700;
}
.live-lbl {
  font-family: var(--cm-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cm-ink-faint);
  padding-left: 5px;
  border-left: 1px solid var(--cm-rule);
  margin-left: 3px;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(31, 122, 62, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(31, 122, 62, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 122, 62, 0); }
}
@keyframes live-pop {
  0%   { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1;   transform: scale(1); }
}

@media (max-width: 720px) {
  .cm-header .brand.brand-big img.brand-logo {
    width: 34px !important;
    height: 34px !important;
    max-height: 34px !important;
  }
  .cm-header .brand.brand-big { padding-bottom: 0; }
  .brand-name { font-size: 18px; }
  .live-lbl { display: none; }
  .live-name { max-width: 80px; }
}

/* ---------- Tablet & small laptop (≤ 980px) ---------- */
@media (max-width: 980px) {
  .cm-header .inner {
    gap: 16px;
    padding: 12px 16px;
  }
  .cm-header nav { gap: 16px; }
  .cm-header nav a { font-size: 13px; }
  .cm-header .right .btn { display: none; }
}

/* ---------- Mobile (≤ 720px) ---------- */
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }

  :root {
    --cm-fs-h1: 28px;
    --cm-fs-h2: 22px;
    --cm-fs-h3: 17px;
    --cm-fs-lead: 15px;
  }

  /* Mobile header: hamburger toggles a drawer that drops below the header */
  .cm-header .inner {
    padding: 10px 14px;
    gap: 8px;
  }
  .cm-header nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--cm-rule);
    box-shadow: 0 8px 14px -8px rgba(0,0,0,0.18);
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
    z-index: 1100;
  }
  .cm-header nav.open { display: flex; }
  .cm-header nav a {
    padding: 12px 16px;
    border-bottom: 1px solid var(--cm-rule-soft);
    font-size: 15px;
    font-weight: 500;
  }
  .cm-header nav a:last-child { border-bottom: 0; }
  .cm-header nav a.active {
    color: var(--cm-accent-700);
    background: var(--cm-paper);
    font-weight: 700;
  }
  .cm-header .right { gap: 6px; margin-left: auto; }
  .cm-header .cm-login { padding: 5px 10px 5px 9px; font-size: 12px; }
  .cm-header .cm-toggle button { padding: 3px 7px; font-size: 10px; }

  /* Container padding */
  .cm-container { padding: 0 16px; }

  /* Hero typography */
  h1 { font-size: 26px !important; line-height: 1.18 !important; }
  h2 { font-size: 20px !important; }
  h3 { font-size: 16px !important; }

  /* /mathimata column headings ("Πλαίσια που ταιριάζουν",
     "Σχολές που ξεκλειδώνονται") — defeat the global h2:20px rule so
     they match the "Μαθήματα Λυκείου" summary on the left column. */
  h2.mat-col-h2 { font-size: 12.5px !important; line-height: 1.3 !important; }

  /* Homepage hero buttons → wrap, full width */
  section[style*="background:var(--cm-navy-700)"] { padding: 40px 0 32px !important; }
  section[style*="background:var(--cm-navy-700)"] a.btn-primary,
  section[style*="background:var(--cm-navy-700)"] a[style*="background:rgba(255,255,255,0.10)"] {
    display: block;
    text-align: center;
  }

  /* All two/three/four-column grids inside main flow → stack */
  main section > .cm-container[style*="grid-template-columns"],
  main section .cm-container > div[style*="grid-template-columns"],
  main section > div[style*="grid-template-columns"] {
    display: block !important;
  }
  main section > .cm-container[style*="grid-template-columns"] > *,
  main section .cm-container > div[style*="grid-template-columns"] > *,
  main section > div[style*="grid-template-columns"] > * {
    margin-bottom: 16px !important;
  }

  /* Footer grid collapse */
  footer .cm-container[style*="grid-template-columns"] {
    display: block !important;
  }
  footer .cm-container > div { margin-bottom: 24px !important; }

  /* Stats strip: 4 cols → 2x2 grid */
  section[style*="border-bottom:1px solid var(--cm-rule)"] .cm-container[style*="grid-template-columns:repeat(4,1fr)"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }

  /* Programs table on mobile: keep Code · Name · Βάση visible; hide Ίδρυμα, Πλαίσιο, Πεδίο */
  table#grid th:nth-child(3),
  table#grid td:nth-child(3),
  table#grid th:nth-child(5),
  table#grid td:nth-child(5),
  table#grid th:nth-child(6),
  table#grid td:nth-child(6) {
    display: none;
  }
  table#grid th, table#grid td {
    padding: 10px 8px !important;
    font-size: 13px !important;
  }
  table#grid td:nth-child(2) {
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  /* Grades inputs: simplify grade-row to stack label over input */
  .grade-row {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
  .grade-row input[type=number] {
    text-align: left !important;
    width: 100% !important;
  }
  .grade-row select { width: 100% !important; }

  /* Grades result row: stack name+forecast above margin */
  .prog-result-row1 {
    grid-template-columns: 1fr auto !important;
    gap: 6px !important;
  }
  .prog-result-row1 .code {
    grid-column: 1 / -1;
    margin-bottom: 2px;
  }
  .prog-result-row1 .name { grid-column: 1 / 2; }
  .prog-result-row1 .forecast { grid-column: 1 / -1; margin-top: 2px; }
  .prog-result-row1 .margin { grid-column: 2 / 3; grid-row: 1; align-self: start; }
  .prog-result-history { font-size: 10px !important; gap: 2px 8px !important; }

  /* Subject explorer: stack columns; results above picker on mobile so the
     consequence of each tap is immediately visible */
  section[style] > .cm-container[style*="grid-template-columns:1fr 1.2fr"] {
    display: flex !important;
    flex-direction: column-reverse !important;
    gap: 20px !important;
  }
  .subj-chip {
    font-size: 12px;
    padding: 5px 12px 5px 10px;
  }
  .fw-card-head { flex-wrap: wrap; }
  .fw-card-head h3 { font-size: 13px; }
  .fw-card-meta { width: 100%; margin-top: 4px; }
  .fw-card-body { font-size: 12px; }

  /* Map: header collapses, sidebar shrinks */
  .map-wrap { grid-template-columns: 1fr !important; height: auto !important; }
  .map-sidebar {
    max-height: none;
    border-right: 0 !important;
    border-bottom: 1px solid var(--cm-rule);
  }
  .map-canvas { height: 70vh; }

  /* Sign-up: stack form + side cards */
  .su-wrap { grid-template-columns: 1fr !important; gap: 16px !important; padding: 24px 0 !important; }
  .su-card { padding: 20px !important; }
  .su-hero h1 { font-size: 26px !important; }

  /* Filter controls row on programs page */
  section > .cm-container > div[style*="display:flex"][style*="flex-wrap:wrap"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  section > .cm-container > div[style*="display:flex"][style*="flex-wrap:wrap"] > * {
    min-width: 0 !important;
    width: 100%;
  }
  section > .cm-container > div[style*="display:flex"][style*="flex-wrap:wrap"] select {
    min-width: 0 !important;
    width: 100%;
  }
}

/* ---------- Small mobile (≤ 380px) ---------- */
@media (max-width: 380px) {
  .cm-header .brand span { font-size: 17px !important; }
  .cm-header nav a { font-size: 12px; }
  h1 { font-size: 22px !important; }
  .cm-container { padding: 0 12px; }
  section[style*="border-bottom:1px solid var(--cm-rule)"] .cm-container[style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ---------- EL/EN toggle: stack vertically when horizontal room runs out ----------
   Login pill (with username when signed in) + logout button + EL/EN toggle can
   overflow on narrow mobile widths, clipping the EN button. Stack EL on top of EN
   so both stay reachable and the toggle keeps a tidy compact pill shape. */
@media (max-width: 480px) {
  .cm-header .cm-toggle {
    flex-direction: column;
    border-radius: 4px;
    line-height: 1;
  }
  .cm-header .cm-toggle button {
    padding: 3px 7px !important;
    font-size: 9.5px !important;
    min-width: 22px;
    letter-spacing: 0.02em;
  }
  /* Subtle inset divider between the two stacked buttons */
  .cm-header .cm-toggle button + button {
    border-top: 1px solid var(--cm-rule);
  }
}
