/* ===========================
   MORAPULSE — learning materials, project by project (loaded after style.css) on:
     morapulse/index.html            the MoraPulse page: logo + a card for each project
     morapulse/<project>/index.html  one landing page per project (Nethra, Sip Saviya)
   A loading screen with the logo, then the page over a very faint moving background.
   js/morapulse.js adds the floating letters and changes the background's theme every
   few seconds: English → Sinhala → Tamil → music → maths, then round again.
=========================== */

/* The MoraPulse page is one screen with no scrolling (class="pulse-html" on its <html>).
   Project pages may scroll once their list of learning materials grows. */
.pulse-html,
.pulse-html .pulse-page {
  height: 100%;
  overflow: hidden;
}

.pulse-page {
  /* Fonts for the floating letters: Poppins for English, then whatever the device has for Sinhala and Tamil */
  --pulse-glyph-font: var(--font), 'Noto Sans Sinhala', 'Noto Sans Tamil', 'Nirmala UI', 'Iskoola Pota', 'Latha',
                    'Sinhala Sangam MN', 'Tamil Sangam MN', 'Segoe UI Symbol', 'Cambria Math', sans-serif;

  /* The page's colours: the club's maroon, red and gold. A project page can change them (see below),
     menu bar included. */
  --pulse-base:        var(--black);      /* background */
  --pulse-deep:        #1A0406;           /* centre of the loading screen, top of the player */
  --pulse-panel-rgb:   14, 2, 3;          /* cards and panels */
  --pulse-accent:      var(--gold);       /* headings, borders, buttons */
  --pulse-accent-light: var(--gold-light);
  --pulse-accent-rgb:  201, 168, 76;
  --pulse-glow-rgb:    204, 0, 0;         /* the glow behind the page, one wave, one line */
  --pulse-on-accent:   var(--black);      /* text and icons on an accent-coloured button */

  background:
    radial-gradient(ellipse at 50% 35%, rgba(var(--pulse-glow-rgb), 0.16), transparent 60%),
    radial-gradient(ellipse at 85% 95%, rgba(var(--pulse-accent-rgb), 0.10), transparent 55%),
    var(--pulse-base);
}

/* Nethra (a vision project): deep navy with sky blue, the colours of its logo */
.pulse-page[data-pulse-theme="nethra"] {
  --pulse-base:        #030B18;
  --pulse-deep:        #0A2142;
  --pulse-panel-rgb:   5, 18, 38;
  --pulse-accent:      #49B1DE;
  --pulse-accent-light: #9BDCF5;
  --pulse-accent-rgb:  73, 177, 222;
  --pulse-glow-rgb:    46, 98, 196;
  --pulse-on-accent:   #031024;

  /* The site's own colour names (css/style.css), so the menu bar turns navy and sky blue on this page too:
     gold → sky blue (links, "of Moratuwa", Mora Connect, ☰), red → blue (the Contact button) */
  --gold:        #49B1DE;
  --gold-light:  #9BDCF5;
  --gold-dark:   #2C7FB0;
  --red:         #2E62C4;
  --red-dark:    #234E9E;
  --border-gold: rgba(73, 177, 222, 0.25);
  --shadow-red:  0 15px 45px rgba(46, 98, 196, 0.3);
}
/* Sip Saviya (an education project): black and yellow, the colours of its logo */
.pulse-page[data-pulse-theme="sipsaviya"] {
  --pulse-base:        #0A0A08;
  --pulse-deep:        #1F1B0C;
  --pulse-panel-rgb:   22, 20, 12;
  --pulse-accent:      #F5C518;
  --pulse-accent-light: #FFE27A;
  --pulse-accent-rgb:  245, 197, 24;
  --pulse-glow-rgb:    224, 150, 0;
  --pulse-on-accent:   #14120A;

  /* the menu bar: gold → yellow, red → amber */
  --gold:        #F5C518;
  --gold-light:  #FFE27A;
  --gold-dark:   #B38E00;
  --red:         #E09A00;
  --red-dark:    #B97F00;
  --border-gold: rgba(245, 197, 24, 0.25);
  --shadow-red:  0 15px 45px rgba(224, 150, 0, 0.3);
}
.pulse-page[data-pulse-theme="sipsaviya"] .navbar.scrolled { background: rgba(10, 10, 8, 0.96); }
.pulse-page[data-pulse-theme="sipsaviya"] .btn-nav:not(.btn-nav-portal) { background: #F5C518 !important; color: #14120A !important; }
.pulse-page[data-pulse-theme="sipsaviya"] .btn-nav:not(.btn-nav-portal):hover { background: #FFE27A !important; }
.pulse-page[data-pulse-theme="sipsaviya"] .btn-nav-portal:hover { color: #14120A !important; box-shadow: 0 0 14px rgba(245, 197, 24, 0.35); }
@media (max-width: 1279px) {
  .pulse-page[data-pulse-theme="sipsaviya"] .nav-links { background: #12110B; }   /* the slide-in menu */
}

/* …and the menu colours css/style.css writes out directly */
.pulse-page[data-pulse-theme="nethra"] .navbar.scrolled { background: rgba(3, 11, 24, 0.96); }
.pulse-page[data-pulse-theme="nethra"] .btn-nav-portal:hover {
  color: #031024 !important;
  box-shadow: 0 0 14px rgba(73, 177, 222, 0.35);
}
@media (max-width: 1279px) {
  .pulse-page[data-pulse-theme="nethra"] .nav-links { background: #061428; }   /* the slide-in menu */
}

/* ---------- Loading screen ---------- */
.pulse-loader {
  position: fixed;
  inset: 0;
  z-index: 1100;                 /* above the menu bar */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  background: radial-gradient(circle at center, var(--pulse-deep), var(--pulse-base) 70%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
  /* If js/morapulse.js never runs, the loading screen still goes away after 6 seconds */
  animation: pulseLoaderAway 0.6s ease 6s forwards;
}

.pulse-loader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes pulseLoaderAway { to { opacity: 0; visibility: hidden; } }

/* The MoraPulse logo, gently glowing and "beating" while the page loads */
.pulse-loader-logo {
  width: min(400px, 76vw);
  height: auto;
  margin-bottom: 0.4rem;
  animation: pulseBeat 1.6s ease-in-out infinite;
}

/* Project pages until their logo arrives: the project's icon in a spinning ring, and its name */
.pulse-loader-mark {
  position: relative;
  width: 120px;
  height: 120px;
  display: grid;
  place-items: center;
  color: var(--pulse-accent);
  font-size: 2.8rem;
}
.pulse-loader-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(var(--pulse-accent-rgb), 0.15);
  border-top-color: var(--pulse-accent);
  border-right-color: rgb(var(--pulse-glow-rgb));
  animation: pulseSpin 1.1s linear infinite;
}
.pulse-loader-mark i { animation: pulseBeat 1.6s ease-in-out infinite; }
.pulse-loader-name {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 1px;
}
@keyframes pulseSpin { to { transform: rotate(360deg); } }

/* A · අ · அ · ♪ · π light up one after another */
.pulse-loader-glyphs {
  display: flex;
  gap: 1.1rem;
  font-family: var(--pulse-glyph-font);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
.pulse-loader-glyphs span {
  color: var(--pulse-accent);
  opacity: 0.2;
  animation: pulseGlow 1.25s ease-in-out infinite;
}
.pulse-loader-glyphs span:nth-child(2) { animation-delay: 0.15s; }
.pulse-loader-glyphs span:nth-child(3) { animation-delay: 0.3s; }
.pulse-loader-glyphs span:nth-child(4) { animation-delay: 0.45s; }
.pulse-loader-glyphs span:nth-child(5) { animation-delay: 0.6s; }

.pulse-loader-text {
  color: var(--text-secondary);
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* Like a heartbeat: two quick swells, then rest (the logo's pulse line) */
@keyframes pulseBeat {
  0%, 40%, 100% { transform: scale(1);     filter: drop-shadow(0 0 10px rgba(var(--pulse-accent-rgb), 0.15)); }
  12%           { transform: scale(1.045); filter: drop-shadow(0 0 26px rgba(var(--pulse-accent-rgb), 0.40)); }
  24%           { transform: scale(1.015); filter: drop-shadow(0 0 16px rgba(var(--pulse-glow-rgb), 0.30)); }
  32%           { transform: scale(1.04);  filter: drop-shadow(0 0 24px rgba(var(--pulse-accent-rgb), 0.35)); }
}
@keyframes pulseGlow  { 30% { opacity: 1; transform: translateY(-5px); text-shadow: 0 0 14px rgba(var(--pulse-accent-rgb), 0.6); } }

/* ---------- Moving background ---------- */
.pulse-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* The big outline letter of the current theme, behind the title. It drifts a little the
   other way from the mouse (--px / --py, set by js/morapulse.js), so the page feels deep. */
.pulse-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pulse-glyph-font);
  font-size: min(78vh, 92vw);
  font-weight: 800;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 2px var(--ghost, rgba(var(--pulse-accent-rgb), 0.14));
  translate: calc(var(--px, 0) * 40px) calc(var(--py, 0) * 40px);
  transition: translate 1.2s ease-out, opacity 0.6s ease, filter 0.6s ease, -webkit-text-stroke-color 0.6s ease;
  animation: pulseBreathe 16s ease-in-out infinite alternate;
}
.pulse-ghost.is-out { opacity: 0; filter: blur(14px); }

@keyframes pulseBreathe {
  from { transform: rotate(-5deg) scale(0.95); }
  to   { transform: rotate(5deg)  scale(1.05); }
}

/* All the floating symbols; moves gently against the mouse */
.pulse-syms {
  position: absolute;
  inset: 0;
  translate: calc(var(--px, 0) * -22px) calc(var(--py, 0) * -22px);
  transition: translate 0.9s ease-out;
}

/* One floating symbol, in three layers:
     .pulse-sym    rises from the bottom to the top (and some twinkle)
     .pulse-sway   sways from side to side
     .pulse-glyph  the letter itself; it melts into a new one when the theme changes
   js/morapulse.js sets for each: --x across, --y (start height, used when motion is switched off),
   --size, --colour, --alpha (how faint), --rise (seconds to cross the screen), --delay, --sway, --spin */
.pulse-sym {
  position: absolute;
  top: 0;
  left: var(--x);
  font-family: var(--pulse-glyph-font);
  font-size: var(--size);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  color: var(--colour);
  opacity: var(--alpha);
  will-change: transform;
  animation: pulseRise var(--rise) linear var(--delay) infinite;
}
.pulse-sym.is-twinkle {
  animation: pulseRise var(--rise) linear var(--delay) infinite,
             pulseTwinkle 5s ease-in-out var(--delay) infinite;
}

.pulse-sway {
  display: block;
  animation: pulseSway calc(var(--rise) / 3) ease-in-out var(--delay) infinite alternate;
}

.pulse-glyph {
  display: block;
  transition: opacity 0.45s ease, filter 0.45s ease, transform 0.45s ease;
}
.pulse-glyph.is-morph { opacity: 0; filter: blur(6px); transform: scale(0.6) rotate(-20deg); }

@keyframes pulseRise {
  from { transform: translate3d(0, 110vh, 0); }
  to   { transform: translate3d(0, -25vh, 0); }
}
@keyframes pulseSway {
  from { transform: translateX(calc(var(--sway) * -1)) rotate(calc(var(--spin) * -1)); }
  to   { transform: translateX(var(--sway)) rotate(var(--spin)); }
}
@keyframes pulseTwinkle {
  50% { opacity: calc(var(--alpha) * 2.6); }
}

/* Letters that burst out where a visitor clicks or taps (js/morapulse.js removes them afterwards) */
.pulse-burst {
  position: absolute;
  left: var(--bx);
  top: var(--by);
  font-family: var(--pulse-glyph-font);
  font-size: var(--size);
  font-weight: 800;
  line-height: 1;
  color: var(--colour);
  animation: pulseBurst 1.2s cubic-bezier(0.15, 0.8, 0.3, 1) forwards;
}
@keyframes pulseBurst {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0.85; }
  to   { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(var(--spin)); opacity: 0; }
}

/* Thin "sound wave" lines across the screen */
.pulse-line {
  position: absolute;
  left: 0;
  width: 200%;
  height: 90px;
  fill: none;
  stroke-width: 1.5;
  animation: pulseWave 30s linear infinite;
}
.pulse-line path   { vector-effect: non-scaling-stroke; }
.pulse-line-1      { top: 24%; stroke: rgba(var(--pulse-accent-rgb), 0.10); }
.pulse-line-2      { top: 66%; stroke: rgba(var(--pulse-glow-rgb), 0.12); animation-duration: 40s; animation-direction: reverse; }

/* Waves along the bottom */
.pulse-waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22vh;
}
.pulse-wave {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 200%;
  height: 100%;
  animation: pulseWave 18s linear infinite;
}
.pulse-wave-1 { fill: rgba(var(--pulse-glow-rgb), 0.08); }
.pulse-wave-2 { fill: rgba(var(--pulse-accent-rgb), 0.06); height: 85%; animation-duration: 26s; animation-direction: reverse; }
.pulse-wave-3 { fill: rgba(255, 255, 255, 0.03); height: 65%; animation-duration: 34s; }

/* Each wave picture is two identical halves, so moving it by half its width loops without a jump */
@keyframes pulseWave { to { transform: translateX(-50%); } }

/* ---------- The page ---------- */
.pulse-main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem 1.5rem 2rem;     /* room for the menu bar */
  text-align: center;
}

.pulse-hero { width: 100%; max-width: 760px; }

.pulse-hero .section-tag { margin-bottom: 1rem; }

/* The page title is the MoraPulse logo: as big as fits, leaving room for the project cards */
.pulse-title {
  line-height: 0;
  margin-bottom: 1.2rem;
}
.pulse-title-logo {
  display: inline-block;
  width: auto;
  height: auto;
  max-width: min(560px, 88vw);
  max-height: 38vh;
  filter: drop-shadow(0 12px 40px rgba(var(--pulse-glow-rgb), 0.22));
}

.pulse-lead {
  color: var(--text-secondary);
  font-size: clamp(0.95rem, 2.2vh, 1.1rem);
  margin-bottom: 1.4rem;
}

/* One card per project; each opens that project's own page */
.pulse-projects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.1rem;
}
.pulse-project {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(330px, 100%);
  padding: 1rem 1.2rem;
  text-align: left;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.25);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(var(--pulse-accent-rgb), 0.09), rgba(var(--pulse-glow-rgb), 0.07)), rgba(var(--pulse-panel-rgb), 0.82);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.pulse-project[hidden] { display: none; }   /* a project switched off in the admin panel */
.pulse-project:hover,
.pulse-project:focus-visible {
  transform: translateY(-4px);
  border-color: var(--pulse-accent);
  box-shadow: 0 14px 40px rgba(var(--pulse-accent-rgb), 0.18);
}
.pulse-project-logo {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--pulse-accent-rgb), 0.25);
  background: radial-gradient(circle, rgba(var(--pulse-accent-rgb), 0.18), rgba(var(--pulse-accent-rgb), 0.03) 70%);
  color: var(--pulse-accent);
  font-size: 1.5rem;
}
.pulse-project-logo img,
.pulse-project-mark img { width: 100%; height: 100%; object-fit: contain; }
.pulse-project-text { flex: 1; line-height: 1.3; }   /* the project's name, beside its logo */
.pulse-project-text strong { color: #fff; font-size: 1.2rem; font-weight: 800; }
.pulse-project-go { color: var(--pulse-accent); transition: transform var(--transition); }
.pulse-project:hover .pulse-project-go { transform: translateX(4px); }

/* A project logo that is dark on white (Nethra) sits on a small white panel */
/* A wide project logo with its own see-through background (Nethra): shown as it is, no circle */
.pulse-project-logo.is-wide {
  width: 108px;
  height: 56px;
  border: none;
  border-radius: 0;
  background: none;
  overflow: visible;
}
.pulse-project-logo.is-wide img { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45)); }
.pulse-loader-wide {
  width: min(360px, 72vw);
  line-height: 0;
  animation: pulseBeat 1.6s ease-in-out infinite;
}
.pulse-loader-wide img { width: 100%; height: auto; }

/* ---------- A project's own page ---------- */
.pulse-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
  padding: 0.45rem 1rem;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.3);
  border-radius: 999px;
  background: rgba(var(--pulse-panel-rgb), 0.7);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}
.pulse-back:hover { color: var(--pulse-accent); border-color: var(--pulse-accent); }

/* A project page with a list (Nethra): starts at the top, left-aligned, and scrolls when long */
.pulse-main--list {
  display: block;
  padding: 6.2rem 0 4rem;
  text-align: left;
}

/* Top left: back button, then the project's logo and name */
.pulse-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.1rem;
  margin-bottom: 2.4rem;
}
.pulse-head .pulse-back { margin-bottom: 0; }
.pulse-head-id {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.pulse-head-logo {
  flex-shrink: 0;
  width: clamp(150px, 16vw, 210px);
  line-height: 0;
}
.pulse-head-logo img { width: 100%; height: auto; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.5)); }
/* Beside the logo: who organises the project */
.pulse-head-note {
  max-width: 470px;
  padding-left: 1.1rem;
  border-left: 2px solid var(--pulse-accent);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.98rem;
  line-height: 1.6;
}

/* ---------- Audio cards ---------- */
.pulse-audio-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
  color: var(--pulse-accent);
  font-size: 1.1rem;
  font-weight: 700;
}
.pulse-audio-count { color: var(--text-secondary); font-size: 0.85rem; font-weight: 500; }

.pulse-audio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2rem;
}

.pulse-audio-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.7rem 0.9rem;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.18);
  border-radius: 18px;
  background: rgba(var(--pulse-panel-rgb), 0.8);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.pulse-audio-card:hover,
.pulse-audio-card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--pulse-accent);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(var(--pulse-accent-rgb), 0.2);
}
.pulse-audio-title { padding: 0 0.2rem; color: #fff; font-size: 0.95rem; font-weight: 700; line-height: 1.3; }
.pulse-audio-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.2rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
}
.pulse-audio-meta i { color: var(--pulse-accent); }

/* An item's picture, 4 : 5 like a 4 × 5 inch photo (the admin panel trims uploads to that shape).
   Behind it, and instead of it when it is missing: the project's colours with sound rings and an icon. */
.pulse-cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 14px;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 22px),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.2), transparent 45%),
    linear-gradient(var(--angle, 135deg), var(--c1, #6B0010), var(--c2, #CC0000));
}
.pulse-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pulse-cover-icon {
  color: rgba(255, 255, 255, 0.92);
  font-size: 2.6rem;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
}

/* ---------- Sip Saviya: subjects and their documents ---------- */

/* A wide logo at the top left (Sip Saviya's is three times as wide as it is tall) */
.pulse-head-logo--wide { width: clamp(220px, 26vw, 340px); }

/* The subject on its own page, next to the logo: icon, English name, Sinhala name */
.pulse-subject-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900;
  line-height: 1.1;
}
.pulse-subject-title i { color: var(--pulse-accent); font-size: 0.8em; }
.pulse-subject-title small { color: var(--text-secondary); font-size: 0.5em; font-weight: 600; }

/* One tile per subject */
.pulse-subjects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.2rem;
}
.pulse-subject {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.3rem 1.2rem;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.22);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(var(--pulse-accent-rgb), 0.08), transparent 60%), rgba(var(--pulse-panel-rgb), 0.85);
  color: inherit;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.pulse-subject:hover,
.pulse-subject:focus-visible {
  transform: translateY(-5px);
  border-color: var(--pulse-accent);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(var(--pulse-accent-rgb), 0.2);
}
.pulse-subject-icon {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--pulse-accent), var(--pulse-accent-light));
  color: var(--pulse-on-accent);
  font-size: 1.45rem;
  box-shadow: 0 10px 24px rgba(var(--pulse-accent-rgb), 0.25);
}
.pulse-subject-text { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.pulse-subject-text strong { color: #fff; font-size: 1.2rem; font-weight: 800; }
.pulse-subject-local { color: var(--text-secondary); font-size: 0.85rem; }
.pulse-subject-count { margin-top: 0.3rem; color: var(--pulse-accent); font-size: 0.72rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.pulse-subject-go { color: var(--pulse-accent); transition: transform var(--transition); }
.pulse-subject:hover .pulse-subject-go { transform: translateX(4px); }
/* A medium's tile shows a letter of its language (අ, A, அ) instead of an icon */
.pulse-subject-letter { font-size: 1.7rem; font-weight: 800; line-height: 1; }

/* On a medium's page, the medium next to the subject's name */
.pulse-medium-pill {
  padding: 0.35em 0.9em;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.45);
  border-radius: 999px;
  background: rgba(var(--pulse-accent-rgb), 0.12);
  color: var(--pulse-accent);
  font-size: 0.4em;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* A subject's documents: one row each, with Open and Download */
.pulse-docs { display: flex; flex-direction: column; gap: 0.9rem; }
.pulse-doc {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.18);
  border-radius: 16px;
  background: rgba(var(--pulse-panel-rgb), 0.85);
}
.pulse-doc-icon {
  flex-shrink: 0;
  width: 48px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 80, 80, 0.12);
  color: #FF6B6B;
  font-size: 1.5rem;
}
.pulse-doc-text { flex: 1; min-width: 0; }
.pulse-doc-text h3 { color: #fff; font-size: 1rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.pulse-doc-about { margin-top: 0.2rem; color: var(--text-secondary); font-size: 0.85rem; }
.pulse-doc-meta { display: block; margin-top: 0.3rem; color: var(--pulse-accent); font-size: 0.72rem; font-weight: 700; letter-spacing: 1px; }
.pulse-doc-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.pulse-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.4);
  border-radius: 999px;
  color: var(--pulse-accent);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
}
.pulse-doc-btn:hover { border-color: var(--pulse-accent); background: rgba(var(--pulse-accent-rgb), 0.1); }
.pulse-doc-btn.is-main { border-color: transparent; background: var(--pulse-accent); color: var(--pulse-on-accent); }
.pulse-doc-btn.is-main:hover { background: var(--pulse-accent-light); }

.pulse-ready .pulse-subject,
.pulse-ready .pulse-doc { animation: pulseUp 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(0.2s + var(--i, 0) * 0.05s); }

/* While there is no audio on the website yet */
.pulse-audio-empty {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.4rem 1.6rem;
  border: 1px dashed rgba(var(--pulse-accent-rgb), 0.35);
  border-radius: 16px;
  background: rgba(var(--pulse-panel-rgb), 0.7);
  color: var(--text-secondary);
}
.pulse-audio-empty i { color: var(--pulse-accent); font-size: 1.2rem; }
.pulse-audio-empty[hidden] { display: none; }

/* The round play button on a card's picture (always shown on touch screens, on hover with a mouse) */
.pulse-audio-go {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pulse-accent), var(--pulse-accent-light));
  color: var(--pulse-on-accent);
  font-size: 0.95rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform var(--transition), opacity var(--transition);
}
.pulse-audio-go i { margin-left: 2px; }    /* the play triangle looks centred */
@media (hover: hover) {
  .pulse-audio-go { opacity: 0; transform: translateY(8px) scale(0.9); }
  .pulse-audio-card:hover .pulse-audio-go,
  .pulse-audio-card:focus-visible .pulse-audio-go { opacity: 1; transform: none; }
}

/* ---------- The player (a dialog over the page) ----------
   Wide (16 : 9) on computers, like its background picture; tall like a phone screen on phones, where the
   same picture fills it (its right-middle part shows). The item's background picture (or else its 4 : 5
   picture, blurred) fills it, and a frosted-glass panel on the left, arched at the top, holds the round
   picture, the title, the controls and "About". js/morapulse-audio.js fills it in. */
.pulse-dialog-open { overflow: hidden; }

.pulse-dialog {
  height: min(88dvh, 860px);
  aspect-ratio: 9 / 16;
  width: auto;
  max-width: calc(100vw - 1rem);
  max-height: calc(100dvh - 1rem);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 26px;
  background: var(--pulse-deep);
  color: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}
.pulse-dialog::backdrop { background: rgba(var(--pulse-panel-rgb), 0.8); backdrop-filter: blur(4px); }
.pulse-dialog[open] { animation: pulseDialogIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pulseDialogIn { from { opacity: 0; transform: translateY(18px) scale(0.97); } }

/* The picture behind everything, darkened a little on the left and at the bottom so the panel reads well */
.pulse-stage {
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--angle, 160deg), var(--c1, #1F3169), var(--c2, #49B1DE));
}
/* object-position: on a tall phone player, the part right of the middle shows — where the subject should be */
.pulse-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 72% 50%; }
.pulse-stage img.is-blurred { filter: blur(18px) brightness(0.72) saturate(1.2); transform: scale(1.25); }
.pulse-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.3), transparent 70%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.3), transparent 40%);
}

.pulse-dialog-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  transition: var(--transition);
}
.pulse-dialog-close:hover { background: rgba(0, 0, 0, 0.6); }

/* The glass panel */
.pulse-glass {
  position: absolute;
  top: 7%;
  bottom: 0;
  left: 0;
  z-index: 1;
  width: clamp(230px, 64%, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(2.2rem, 9%, 3.4rem) 1.1rem 1.2rem;
  overflow-y: auto;                         /* a long "About" scrolls inside the panel */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.32);
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50% 50% 0 0 / 14% 14% 0 0; /* the arched top */
  background: rgba(255, 255, 255, 0.13);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
}

.pulse-dialog-kicker {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.6;
  text-transform: uppercase;
}
.pulse-dialog-kicker span { display: block; }

/* The round picture: turns slowly, like a record, while the sound plays */
.pulse-disc {
  flex-shrink: 0;
  width: clamp(104px, 44%, 150px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 1rem 0 0.9rem;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c1, #1F3169), var(--c2, #49B1DE));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 0 4px rgba(255, 255, 255, 0.16);
}
.pulse-disc img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: pulseRecord 18s linear infinite paused;
}
.pulse-disc .pulse-cover-icon { font-size: 2.4rem; }
.pulse-dialog.is-playing .pulse-disc img { animation-play-state: running; }
@keyframes pulseRecord { to { transform: rotate(360deg); } }

.pulse-dialog-title {
  font-size: clamp(1.15rem, 2.6vh, 1.5rem);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.pulse-dialog-sub { margin-top: 0.15rem; color: rgba(255, 255, 255, 0.8); font-size: 0.85rem; }

.pulse-player { width: 100%; margin-top: 1rem; }

/* The bar: white up to where the sound is (--p, set by js/morapulse-audio.js) */
.pulse-seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, #fff var(--p, 0%), rgba(255, 255, 255, 0.3) var(--p, 0%));
  cursor: pointer;
}
.pulse-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}
.pulse-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}
.pulse-times {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

/* Back 10 s · previous · play · next · forward 10 s */
.pulse-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  margin-top: 0.6rem;
}
.pulse-ctrl {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}
.pulse-ctrl:hover { background: rgba(255, 255, 255, 0.15); }
.pulse-ctrl:disabled { opacity: 0.35; cursor: default; background: none; }
.pulse-play-btn {
  width: 54px;
  height: 54px;
  background: #fff;
  color: #0C1424;
  font-size: 1.2rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
}
.pulse-play-btn:hover { background: #fff; transform: scale(1.06); }
.pulse-play-btn .fa-play { margin-left: 3px; }   /* the play triangle looks centred */
.pulse-player-msg { min-height: 1em; margin-top: 0.4rem; color: #FFD0D0; font-size: 0.78rem; }

/* "Voice by": who reads the item — a small glass strip with a microphone */
.pulse-voice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}
.pulse-voice[hidden] { display: none; }
.pulse-voice-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #0C1424;
  font-size: 0.95rem;
}
.pulse-voice-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pulse-voice-text small { color: rgba(255, 255, 255, 0.7); font-size: 0.66rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.pulse-voice-text b { color: #fff; font-size: 0.95rem; font-weight: 700; overflow-wrap: anywhere; }

/* "About": the item's description, like the lyrics part of a music player */
.pulse-about { width: 100%; margin-top: 0.6rem; text-align: left; }
.pulse-about[hidden] { display: none; }
.pulse-about h3 { margin-bottom: 0.3rem; font-size: 1.15rem; font-weight: 800; }
.pulse-dialog-about { color: rgba(255, 255, 255, 0.88); font-size: 0.85rem; line-height: 1.55; }

/* The project's logo (an icon until the real logo arrives) */
.pulse-project-mark {
  width: clamp(96px, 16vh, 140px);
  height: clamp(96px, 16vh, 140px);
  margin: 0 auto 1.2rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--pulse-accent-rgb), 0.25);
  background: radial-gradient(circle, rgba(var(--pulse-accent-rgb), 0.16), rgba(var(--pulse-accent-rgb), 0.03) 70%);
  box-shadow: 0 0 45px rgba(var(--pulse-accent-rgb), 0.14);
  color: var(--pulse-accent);
  font-size: clamp(2.4rem, 6vh, 3.4rem);
}

.pulse-project-name {
  font-size: clamp(2.6rem, min(11vw, 12vh), 5.5rem);
  font-weight: 900;
  line-height: 1.05;
  margin-bottom: 2rem;
  background: linear-gradient(90deg, #fff 35%, var(--pulse-accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pulse-materials {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 1.4rem 1.6rem;
  text-align: left;
  border: 1px solid rgba(var(--pulse-accent-rgb), 0.25);
  border-radius: 16px;
  background: rgba(var(--pulse-panel-rgb), 0.82);
}
.pulse-materials h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  color: var(--pulse-accent);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.pulse-empty { color: var(--text-secondary); font-size: 0.92rem; }

/* When the loading screen goes, the page rises into place one part after another */
.pulse-ready .pulse-hero > * { animation: pulseUp 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.pulse-ready .pulse-hero > :nth-child(2) { animation-delay: 0.08s; }
.pulse-ready .pulse-hero > :nth-child(3) { animation-delay: 0.16s; }
.pulse-ready .pulse-hero > :nth-child(4) { animation-delay: 0.24s; }
.pulse-ready .pulse-hero > :nth-child(5) { animation-delay: 0.32s; }
.pulse-ready .pulse-head > *,
.pulse-ready .pulse-audio-heading { animation: pulseUp 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.pulse-ready .pulse-head > :nth-child(2) { animation-delay: 0.08s; }
.pulse-ready .pulse-audio-heading      { animation-delay: 0.16s; }
.pulse-ready .pulse-audio-card { animation: pulseUp 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(0.2s + var(--i, 0) * 0.05s); }

@keyframes pulseUp { from { opacity: 0; transform: translateY(24px); } }

/* Phones */
@media (max-width: 480px) {
  .pulse-hero .section-tag { letter-spacing: 3px; gap: 0.7rem; }   /* "Leo Club of Moratuwa" stays on one line */
  .pulse-hero .section-tag::before,
  .pulse-hero .section-tag::after { width: 24px; }
  .pulse-waves  { height: 16vh; }
  .pulse-project { padding: 0.85rem 1rem; }
  .pulse-materials { padding: 1.2rem; }
  .pulse-main--list { padding-top: 5.4rem; }
  .pulse-head-logo { width: 150px; }
  .pulse-head-id   { flex-direction: column; align-items: flex-start; gap: 0.9rem; }   /* the note goes under the logo */
  .pulse-head-note { font-size: 0.9rem; }
  .pulse-audio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
  .pulse-head-logo--wide { width: 240px; }
  .pulse-subjects { grid-template-columns: 1fr; gap: 0.8rem; }
  .pulse-doc { flex-wrap: wrap; }
  .pulse-doc-actions { width: 100%; }
  .pulse-doc-btn { flex: 1; justify-content: center; }
  .pulse-cover-icon { font-size: 2.1rem; }
}

/* Computers and tablets turned sideways: the player is wide (16 : 9), the shape of its background picture */
@media (min-width: 720px) and (orientation: landscape) {
  .pulse-dialog { height: auto; width: min(1100px, calc(100vw - 2rem), calc((100dvh - 4rem) * 16 / 9)); aspect-ratio: 16 / 9; }
  .pulse-glass  { width: clamp(300px, 36%, 400px); }
  .pulse-disc   { width: clamp(96px, 30%, 130px); }
}

/* The player on a short, wide screen (a phone turned sideways): wider than tall, the panel on the left half */
@media (max-height: 560px) and (orientation: landscape) {
  .pulse-dialog { aspect-ratio: auto; width: min(760px, calc(100vw - 1rem)); height: calc(100dvh - 1rem); }
  .pulse-glass  { top: 0; width: 56%; padding-top: 1.2rem; border-radius: 0; }
  .pulse-disc   { width: 84px; margin: 0.6rem 0; }
}

/* Short screens (a phone turned sideways): smaller logo and cards so everything fits under the menu bar */
@media (max-height: 520px) {
  .pulse-main       { padding-top: 4.2rem; padding-bottom: 1rem; }
  .pulse-hero .section-tag { margin-bottom: 0.6rem; }
  .pulse-title      { margin-bottom: 0.8rem; }
  .pulse-title-logo { max-height: 30vh; }
  .pulse-lead       { display: none; }
  .pulse-project    { padding: 0.65rem 1rem; }
  .pulse-project-logo { width: 46px; height: 46px; font-size: 1.15rem; }
  .pulse-loader-logo { width: min(300px, 60vw); }
}

/* Visitors who ask for less motion: the symbols and waves stay still (the theme still changes) */
@media (prefers-reduced-motion: reduce) {
  .pulse-sym,
  .pulse-sway,
  .pulse-line,
  .pulse-wave,
  .pulse-ghost,
  .pulse-disc img { animation: none !important; }
  .pulse-sym   { transform: translate3d(0, var(--y), 0); }
}
