/* The portal's shared shell: theme, page background, header and nav.
 *
 * Every public page links this. It exists because the header was copy-pasted
 * into five pages and drifted twice — nav type ended up 13px on some pages and
 * 15px on others, the brand 17px against 19px. One file, one answer.
 *
 * It is a plain stylesheet served straight from frontend/: no build step, and
 * "edit the file, reload the page" still works.
 *
 * A page picks its own manuscript background by setting --sheet on :root, e.g.
 *   :root { --sheet: url('/static/img/cuntanu-svetilna.jpg'); }
 * Leave it unset and the page simply has none.
 */
:root {
  --bg: #12100e; --panel: #1c1916; --panel2: #262019; --line: #3a322a;
  --text: #f3ece0; --muted: #a99e8c; --gold: #c9a25f; --gold2: #e0c081;
  --ok: #6fbf73; --bad: #d05b5b;
  /* buttons sit lighter than the page so they read as raised; fields sit
     darker so they read as recessed */
  --btn: #3a3128; --btn-hover: #4a4034;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 'EB Garamond', Georgia, 'Times New Roman', serif;
  /* Sticky footer: a short page (an almost-empty section, say) would otherwise
     leave the footer floating in the middle of the screen. The fixed-position
     background layers below are out of flow, so they aren't flex items. */
  min-height: 100vh; display: flex; flex-direction: column;
}
header { flex: none; }
/* width:100% matters: each .wrap sets `margin: 0 auto`, and an auto cross-axis
   margin on a flex item overrides the default stretch, shrinking it to its
   content and centring everything inside it. */
.wrap { flex: 1 0 auto; width: 100%; }
footer { flex: none; }
a { color: inherit; text-decoration: none; }
/* Form controls inherit neither type nor colour, so without this a <button>
   renders as a white system button on a near-black page. */
button, input, select, textarea {
  font: inherit; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px;
}
input, textarea, select { background: var(--bg); }
button { background: var(--btn); cursor: pointer; transition: .12s; }
button:hover { background: var(--btn-hover); border-color: var(--gold); }
/* Checkboxes would otherwise be system blue against all this brown. */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--gold); padding: 0; border: 0;
}

/* A page of Cunțan's 1932 "Cântările bisericești" behind the content —
   inverted so the notation reads as faint gold on the dark ground, and faded
   out toward the bottom so footers sit on clean colour. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: var(--sheet, none) center top / cover no-repeat;
  filter: invert(1) sepia(1) saturate(.7) hue-rotate(5deg);
  opacity: .07;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(18,16,14,0) 0%, rgba(18,16,14,.55) 62%,
                                      rgba(18,16,14,.92) 100%);
}

/* ----------------------------- header ----------------------------------- */
header {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px;
  background: rgba(28,25,22,.88); backdrop-filter: blur(6px);
}
header .brand { font-size: 20px; font-weight: 600; letter-spacing: .3px; }
header .brand span { color: var(--gold); }
header .brand .cross { color: var(--gold); margin-right: 5px; }
/* The brand is also a press target — holding it opens the splitter — so stop
   the hold from selecting the text under the cursor. */
.brandlink { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ----------------------------- nav -------------------------------------- */
nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
nav a, .navbtn {
  padding: 8px 13px; border-radius: 8px; color: var(--muted);
  font: inherit; font-size: 16px; background: transparent; border: 0;
  cursor: pointer; line-height: 1.3;
}
nav a:hover, .navbtn:hover { color: var(--text); background: var(--panel2); }
nav a.active, .navbtn.active, .navmenu.open .navbtn { color: var(--gold2); }

.navmenu { position: relative; }
.navpop {
  display: none; position: absolute; right: 0; top: 40px; z-index: 40;
  min-width: 176px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: 0 10px 28px rgba(0,0,0,.5);
}
.navmenu.open .navpop { display: block; }
.navpop a { display: block; padding: 8px 11px; border-radius: 7px; color: var(--text); }
.navpop a:hover { background: var(--line); }

/* ----------------------------- collapsed nav ---------------------------- */
/* Below 720px the five nav items plus the brand no longer fit on one line —
 * they wrapped, then clipped off the right edge once "Calendar" was added — so
 * the whole nav folds into one menu behind a button.
 *
 * Everything here is gated on [data-nav="collapsible"], which shell.js sets
 * once it has inserted the button. Without JS the attribute never appears, the
 * rules never apply, and the nav stays a plain (wrapping) row rather than
 * becoming a menu with nothing to open it.
 */
.navtoggle { display: none; }

@media (max-width: 720px) {
  /* z-index, not just position: the header's backdrop-filter makes it a
     stacking context, so the panel's own z-index below is confined inside it.
     Without lifting the whole header, anything positioned later in the page —
     .rule, a card — paints straight over the open menu. */
  header { padding: 12px 14px; gap: 10px; position: relative; z-index: 50; }
  header .brand { font-size: 17px; }

  header[data-nav="collapsible"] .navtoggle {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    margin-left: auto; padding: 9px 10px; border-radius: 9px;
    background: transparent; border: 1px solid var(--line);
  }
  .navtoggle span {
    display: block; width: 18px; height: 2px; border-radius: 2px;
    background: var(--muted); transition: .15s;
  }
  header.navopen .navtoggle { background: var(--panel2); }
  header.navopen .navtoggle span { background: var(--gold2); }

  /* The panel hangs under the header, full width, one row per destination. */
  header[data-nav="collapsible"] nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    z-index: 45; margin-left: 0; flex-direction: column; align-items: stretch;
    gap: 2px; padding: 6px; background: var(--panel2);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 30px rgba(0,0,0,.55);
  }
  header[data-nav="collapsible"].navopen nav { display: flex; }
  header[data-nav="collapsible"] nav > a,
  header[data-nav="collapsible"] nav .navbtn {
    display: block; width: 100%; text-align: left; padding: 11px 13px;
    font-size: 16px; border-radius: 8px;
  }

  /* "Fun Stuff" keeps its own toggle, but expands in flow instead of floating
     a second popup over the first — stacked popups are unusable on a phone. */
  header[data-nav="collapsible"] nav .navmenu { position: static; }
  header[data-nav="collapsible"] nav .navpop {
    position: static; min-width: 0; margin: 2px 0 2px 10px; padding: 2px;
    background: transparent; border: 0; border-left: 1px solid var(--line);
    border-radius: 0; box-shadow: none;
  }
  header[data-nav="collapsible"] nav .navpop a { padding: 10px 12px; }
}

/* A hairline broken by a cross — the portal's section divider. Put
   <div class="rule"></div> wherever a break is wanted. The cross sits on a
   patch of page colour so the line appears to pass behind it. */
.rule {
  width: 92px; height: 1px; background: var(--gold); opacity: .5;
  margin: 22px auto; position: relative;
}
.rule::after {
  content: "\271B"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); background: var(--bg); color: var(--gold);
  padding: 0 10px; font-size: 13px; opacity: 1;
}
 /* Under a left-aligned page title the centred rule floats away from it, so
    this variant sits under the heading it belongs to. */
.rule.tight { margin: 14px 0 24px; }

/* A MuseScore file downloads instead of opening a viewer — worth saying before
   the click rather than after it. Shown on hover, and on keyboard focus so it
   isn't a surprise for anyone tabbing through. */
.hint {
  font-size: 13px; color: var(--muted); font-style: italic; flex: none;
  white-space: nowrap; opacity: 0; transition: opacity .12s;
}
.row:hover .hint, .row:focus-within .hint,
.it:hover .hint, .it:focus-within .hint { opacity: 1; }
@media (max-width: 700px) { .hint { display: none; } }

/* ----------------------------- footer ----------------------------------- */
footer {
  color: var(--muted); font-size: 13.5px; text-align: center;
  padding: 8px 20px 46px; line-height: 1.75; margin-top: 44px;
}
footer a { color: var(--gold2); }
footer a:hover { text-decoration: underline; }
footer .terms {
  display: block; max-width: 640px; margin: 10px auto 0; font-size: 13px;
}
footer .credit { display: block; font-size: 11.5px; opacity: .62; margin-top: 10px; }
