/* ==========================================================================
   SAMT - the frame every page shares: the header, the astrolabe and orbit
   behind the top of the page, and the footer. The markup comes from
   assets/js/layout.js; each page only brings its own content.
   ========================================================================== */

/* ---- header glass ---- */
html.dark .glass-nav {
  background: rgba(7, 10, 18, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
html:not(.dark) .glass-nav {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid #E2E8F0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

/* ---- theme switch: the icon is drawn by CSS so it never flashes the wrong one ---- */
.theme-toggle-icon::before {
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}
html.dark .theme-toggle-icon::before { content: "\f185" !important; } /* sun */
html.dark .theme-toggle-icon { color: #00F5D4 !important; }
html:not(.dark) .theme-toggle-icon::before { content: "\f186" !important; } /* moon */
html:not(.dark) .theme-toggle-icon { color: #00BBF9 !important; }

/* ---- the astrolabe and orbit behind the top of every page ---- */
html.dark .astrolabe-layer { opacity: 0.14; }
html:not(.dark) .astrolabe-layer { opacity: 0.035; }
@keyframes spinAstrolabe {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.animate-astrolabe { animation: spinAstrolabe 80s linear infinite; }

/* ---- phones ---- */

/* Android browsers (Chrome, Brave, Samsung Internet, MIUI...) each inflate
   page text by a different amount. That is why the header fitted on one
   phone and wrapped onto two lines on another. Pin it so every browser
   renders the same size. */
html { -webkit-text-size-adjust: 100%; -moz-text-size-adjust: 100%; text-size-adjust: 100%; }
/* `clip` contains horizontal overflow WITHOUT creating a scroll container.
   Plain `hidden` here silently breaks every `position: sticky` on the page. */
html, body { overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }

/* backdrop-filter is by far the most expensive effect on these pages, and it
   is used ~48 times, stacked over an animated background - so the browser
   can never cache any of it. Mid-range phones respond by discarding painted
   tiles, which is what showed up as blank areas while scrolling fast. Below
   900px (and on any touch device) the frosted glass becomes a plain solid
   panel, which looks nearly identical over a dark sky. */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .glass-card, header, .samt-app, #themeToggle, .btn-samt-glow {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .glass-card { background-color: rgba(13, 21, 42, .94) !important; }
  header      { background-color: rgba(7, 10, 18, .96) !important; }
  /* a 30px blur behind every program card, on top of everything else */
  .samt-media-bg { filter: none !important; opacity: .25 !important; }
  .samt-shine { display: none !important; }
  .samt-app:hover { transform: none !important; }
}

/* the header is a single row that must never wrap or grow taller */
header .max-w-7xl { flex-wrap: nowrap !important; }
header a.group, header #themeToggle { flex-shrink: 0; }
header a.group span { white-space: nowrap; }

@media (max-width: 640px) {
  header .max-w-7xl { padding-left:.7rem !important; padding-right:.7rem !important; }
  header a .w-10.h-10 { width:2rem !important; height:2rem !important; }
  header a span.text-2xl { font-size:1.1rem !important; }
  header a span.text-xl { font-size:.8rem !important; letter-spacing:.05em !important; }
  header a.group { gap:.45rem !important; }
  header .max-w-7xl > div.flex.items-center.gap-3 { gap:.35rem !important; }
  header button.md\:hidden { padding:.25rem !important; }
}

/* narrow phones (most Android handsets report 360-412px) */
@media (max-width: 420px) {
  header a .w-10.h-10 { width:1.7rem !important; height:1.7rem !important; }
  header a span.text-2xl { font-size:.95rem !important; }
  header a span.text-xl { font-size:.7rem !important; }
  header a.group { gap:.35rem !important; }
  header .max-w-7xl > div.flex.items-center.gap-3 { gap:.25rem !important; }
  header #themeToggle { width:2rem !important; height:2rem !important; }
}

/* very small screens: the latin wordmark is the first thing to go */
@media (max-width: 340px) {
  header a span.text-xl { display:none !important; }
}
