/* ==========================================================================
   bridgealbena.org — shared styles for header, menu, layout, calendar, footer
   Page-specific styles (results tables, scorecards…) stay in each page.
   ========================================================================== */

:root {
  --navy: #26354a;
  --navy-dark: #1b2738;
  --gold: #ffcc00;
  --gold-light: #fff3b0;
  --gold-hover: #ffe566;
  --gold-border: #cc9900;
  --orange: #ff8c00;
  --red: #d40000;
  --blue: #3366cc;
  --blue-light: #c0dffd;
  --green-light: #ccff99;
  --panel: #d3dce6;
  --text: #222;
  --radius: 6px;
  --sidebar-w: 240px;
  --max-w: 1280px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
  background: var(--navy);
  color: var(--text);
}

img { max-width: 100%; height: auto; }

/* Custom elements are inline by default — make them blocks. */
site-header, site-footer, site-calendar { display: block; }
/* Reserve space before JS runs, so the page doesn't jump. */
site-header:not([data-ready]) { min-height: 210px; background: #fff; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--gold); color: #000; padding: 8px 14px; z-index: 1000; font-weight: bold;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Header ---------- */
.site-header {
  background: #fff;
  /* logo | title (centred on the page) | Albena logo – side columns are equal, so the text is truly centred */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(12px, 3vw, 28px);
}
.brand-logo { justify-self: start; display: block; }
.brand-logo img { display: block; width: clamp(64px, 10vw, 120px); height: auto; }
.brand { text-align: center; text-decoration: none; min-width: 0; }
.brand-name {
  display: block; color: red;
  font-family: "Times New Roman", Georgia, serif;
  font-size: clamp(1.3rem, 3.5vw, 2.1rem); font-weight: bold; line-height: 1.15;
}
.brand-tagline {
  display: block; color: #3366ff; font-style: italic; font-weight: bold;
  font-size: clamp(0.95rem, 2vw, 1.4rem); margin-top: 4px;
}
.partner { justify-self: end; display: block; }
.partner img { width: clamp(90px, 12vw, 150px); height: auto; display: block; }

/* ---------- Main menu ---------- */
.site-nav {
  background: var(--gold);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.nav-toggle { display: none; }
.menu {
  list-style: none; margin: 0 auto; padding: 0 10px;
  max-width: var(--max-w);
  display: flex; flex-wrap: wrap; justify-content: center;
}
.menu-item { position: relative; }
.menu-item + .menu-item { border-left: 1px solid rgba(0,0,0,.45); }

.menu-link, .menu-top {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  font: bold 0.95rem Arial, sans-serif; color: #000;
  text-decoration: none; white-space: nowrap;
  background: none; border: 0; cursor: pointer;
  transition: background .15s;
}
.menu-link:hover, .menu-top:hover,
.menu-link:focus-visible, .menu-top:focus-visible { background: var(--gold-hover); }
.menu-item.is-active > .menu-link,
.menu-item.is-active > .menu-top { color: var(--red); background: var(--gold-light); }

.arrow { font-size: .75em; transition: transform .2s; }
.has-sub.open > .menu-top .arrow { transform: rotate(180deg); }

.submenu {
  list-style: none; margin: 0; padding: 0;
  display: none;
  position: absolute; top: 100%; left: 0; min-width: 220px;
  background: #ffdd44; border-top: 2px solid var(--gold-border);
  box-shadow: 0 6px 14px rgba(0,0,0,.25);
}
.has-sub.open > .submenu { display: block; }
.submenu a {
  display: block; padding: 10px 16px;
  color: #000; font-weight: bold; font-size: .9rem; text-decoration: none;
  border-bottom: 1px solid var(--gold-border); white-space: nowrap;
}
.submenu li:last-child a { border-bottom: 0; }
.submenu a:hover, .submenu a:focus-visible { background: var(--gold-light); color: var(--red); }
.submenu a[aria-current="page"] { background: var(--gold-light); color: var(--red); }

/* Second level (OBZOR → RESULTS → …) */
.has-sub2 { position: relative; }
.sub-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 10px 16px;
  background: none; border: 0; border-bottom: 1px solid var(--gold-border);
  font: bold .9rem Arial, sans-serif; color: #000; cursor: pointer; text-align: left;
}
.sub-top:hover, .sub-top:focus-visible,
.has-sub2.open > .sub-top { background: var(--gold-light); color: var(--red); }
.has-sub2:last-child > .sub-top { border-bottom: 0; }
.submenu2 {
  list-style: none; margin: 0; padding: 0;
  display: none;
  position: absolute; top: 0; left: 100%; min-width: 240px;
  background: #fff8d6; border-left: 2px solid var(--gold-border);
  box-shadow: 4px 4px 12px rgba(0,0,0,.2);
}
.has-sub2.open > .submenu2 { display: block; }
.submenu2 a { font-size: .85rem; border-bottom-color: #e0c840; }
.submenu2 a:hover, .submenu2 a:focus-visible { background: var(--gold); }

/* Desktop: also open on hover (for mouse users) */
@media (hover: hover) and (min-width: 801px) {
  .has-sub:hover > .submenu { display: block; }
  .has-sub2:hover > .submenu2 { display: block; }
}

/* ---------- Page layout ---------- */
.layout {
  flex: 1;
  width: 100%; max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px clamp(10px, 2vw, 20px);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
/* Page without calendar → content takes full width */
.layout:not(:has(site-calendar)) { grid-template-columns: minmax(0, 1fr); }
.layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }

.content {
  background: var(--panel);
  padding: clamp(12px, 2vw, 24px);
  border-radius: var(--radius);
  min-width: 0;
}

/* ---------- Calendar of events ---------- */
.calendar {
  background: var(--navy-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px;
  position: sticky; top: 64px;
}
.calendar-logo { width: 100%; display: block; border-radius: 4px; }
.calendar h2 {
  margin: 12px 0 8px; text-align: center;
  color: var(--orange); font-size: 1.2rem; font-weight: normal;
}
.ticker {
  height: 300px; overflow: hidden; position: relative;
  -webkit-mask-image: linear-gradient(transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(transparent, #000 8%, #000 92%, transparent);
}
.ticker:not(.is-animated) { height: auto; max-height: 420px; overflow-y: auto; -webkit-mask-image: none; mask-image: none; }
.ticker-track { list-style: none; margin: 0; padding: 0; }
.ticker.is-animated .ticker-track { animation: ticker var(--ticker-duration, 30s) linear infinite; }
.ticker.is-animated:hover .ticker-track,
.ticker.is-animated:focus-within .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateY(0); } to { transform: translateY(-50%); } }

.event {
  padding: 8px 4px; border-bottom: 1px dashed rgba(255,255,255,.2);
  font-size: .9rem;
}
/* Colours kept from the old external.htm: green titles, amber details */
.event-title { display: block; color: #00ff00; font-weight: bold; text-decoration: none; }
a.event-title:hover, a.event-title:focus-visible { color: #fff; text-decoration: underline; }
.event-title sup { font-size: .7em; }
.event-place { display: block; color: #ffba00; font-size: .85rem; }
.event time { display: block; color: #ffba00; font-size: .85rem; }
.event.past { opacity: .6; }
.event-divider {
  margin: 10px 0 4px; padding: 4px 6px; border-radius: 3px; text-align: center;
  font-size: .75rem; font-weight: bold; text-transform: uppercase; letter-spacing: .12em;
}
.event-divider.upcoming { background: #00a000; color: #fff; }               /* green, like the event titles */
.event-divider.past     { background: rgba(255,255,255,.12); color: #c9d4e3; } /* muted, like the past events */
.event-divider:first-child { margin-top: 0; }

/* ---------- Invitation poster with EN/BG switch (primorsko, obzor, …) ---------- */
.lang-switch { display: flex; gap: 8px; margin-bottom: 16px; }
.lang-switch button {
  padding: 8px 14px; border: 0; border-radius: 4px; cursor: pointer;
  background: #ff6600; color: #fff; font-weight: bold; font-size: .95rem;
}
.lang-switch button:hover { background: #e65c00; }
.lang-switch button[aria-pressed="true"] { background: #b34700; }
.invitation { width: 100%; height: auto; border: 1px solid #666; display: block; }

/* ---------- Results pages: title bar + table with download buttons ---------- */
.results-header {
  background: var(--navy); color: var(--gold);
  padding: 14px 20px; margin-bottom: 20px; border-radius: 4px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.results-header h1 {
  margin: 0; font-family: "Times New Roman", Georgia, serif;
  font-size: clamp(1.1rem, 2.5vw, 1.4rem); font-weight: bold; letter-spacing: .5px;
}
.back-link {
  color: var(--gold); text-decoration: none; font-size: .8rem; font-weight: bold;
  border: 1px solid var(--gold); padding: 4px 10px; border-radius: 3px; white-space: nowrap;
}
.back-link:hover, .back-link:focus-visible { background: rgba(255,204,0,.2); }

.table-scroll {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 4px;
  /* shadows at the edges show there is more to scroll */
  background:
    linear-gradient(to right, var(--panel) 30%, transparent),
    linear-gradient(to left,  var(--panel) 30%, transparent),
    linear-gradient(to right, rgba(0,0,0,.12), transparent 20px),
    linear-gradient(to left,  rgba(0,0,0,.12), transparent 20px);
  background-attachment: local, local, scroll, scroll;
}
.scroll-hint { display: none; text-align: center; font-size: .7rem; color: #667; margin: 0 0 4px; letter-spacing: .5px; }

.results-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: .82rem; }
.results-table thead th {
  background: var(--navy); color: var(--gold);
  padding: 10px; text-align: center; font-size: .75rem; letter-spacing: .3px; white-space: nowrap;
}
.results-table thead th:first-child { text-align: left; }
.results-table tbody tr { border-bottom: 1px solid #a0b8d0; }
.results-table tbody tr:nth-child(even) { background: #c4d3e0; }
.results-table tbody tr:hover { background: #b0c6d8; }
.results-table td, .results-table tbody th { padding: 10px; vertical-align: middle; text-align: center; }
.results-table td:first-child, .results-table th[scope="row"] {
  text-align: left; font-weight: bold; color: #1a2a3a;
}
.results-table .empty { color: #999; }

a.dl-link {
  display: inline-block; background: var(--navy); color: var(--gold);
  padding: 4px 11px; border-radius: 3px; font-size: .75rem; font-weight: bold;
  white-space: nowrap; text-decoration: none; transition: background .15s, color .15s;
}
a.dl-link:hover, a.dl-link:focus-visible { background: #cc0000; color: #fff; }

@media (max-width: 600px) {
  .scroll-hint { display: block; }
  .results-table { font-size: .7rem; min-width: 480px; }
  .results-table thead th, .results-table td, .results-table tbody th { padding: 7px 5px; }
  .results-table td:first-child, .results-table th:first-child { min-width: 130px; }
  a.dl-link { padding: 3px 6px; font-size: .7rem; }
}

/* ---------- Albena festival pages ---------- */
festival-banner { display: block; }
festival-banner:not([data-ready]) { min-height: 200px; }
body[data-section="albena"] .content { background: var(--blue-light); color: #003366; }

.festival-banner {
  background: var(--blue); color: #fff; text-align: center;
  margin: calc(-1 * clamp(12px, 2vw, 24px)) calc(-1 * clamp(12px, 2vw, 24px)) 20px;
  border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
  border-bottom: 4px solid var(--green-light);
}
.festival-title {
  margin: 0; padding: 16px 12px 10px;
  font: bold clamp(1.15rem, 2.6vw, 1.7rem) "Trebuchet MS", Arial, sans-serif; letter-spacing: .5px;
}
.festival-title sup { font-size: .6em; }
.festival-image img { display: block; width: 100%; max-height: 95px; object-fit: cover; }
.festival-tagline { margin: 0; padding: 10px 12px 12px; font-style: italic; font-size: clamp(.9rem, 1.8vw, 1.05rem); }

.page-title {
  margin: 0 0 18px; padding-bottom: 8px; border-bottom: 2px solid var(--blue);
  font: bold clamp(1.3rem, 2.8vw, 1.75rem) "Trebuchet MS", Arial, sans-serif; color: #003366;
}
.festival-text h2 {
  margin: 28px 0 10px; color: var(--blue);
  font: bold 1.1rem "Trebuchet MS", Arial, sans-serif; text-transform: uppercase; letter-spacing: .5px;
}
.festival-text p { text-align: justify; }
.festival-banner p { text-align: center; }
.festival-text a { color: var(--blue); font-weight: bold; }

/* Cross-fading photos (see startSlideshows in site.js) */
.slideshow { position: relative; aspect-ratio: 18 / 13; overflow: hidden; border-radius: 4px; background: #fff; }
.slideshow img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s; }
.slideshow img.show { opacity: 1; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--green-light);
  color: #333;
  text-align: center;
  font-size: .85rem;
  padding: 12px 20px;
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: #003366; font-weight: bold; }

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .calendar { position: static; order: 2; }          /* calendar goes under the content */
  .layout > main { order: 1; }
  site-calendar { order: 2; }
  .ticker { height: 220px; }

  .nav-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 12px 16px; border: 0; background: none;
    font: bold 1rem Arial, sans-serif; cursor: pointer;
  }
  .menu { display: none; flex-direction: column; padding: 0; }
  .site-nav.open .menu { display: flex; }
  .menu-item + .menu-item { border-left: 0; border-top: 1px solid var(--gold-border); }
  .menu-link, .menu-top { width: 100%; justify-content: space-between; padding: 14px 16px; }
  .menu-link { justify-content: flex-start; }
  .submenu { position: static; box-shadow: none; border-top: 0; border-left: 6px solid var(--gold-border); }
  .submenu2 { position: static; box-shadow: none; border-left: 10px solid var(--gold-border); }
  .sub-top .arrow { transform: rotate(90deg); }
  .has-sub2.open > .sub-top .arrow { transform: rotate(-90deg); }
}

@media (max-width: 480px) {
  site-header:not([data-ready]) { min-height: 140px; }
  .site-header { grid-template-columns: auto 1fr; }
  .partner { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  site-header, site-footer, site-calendar, .site-nav { display: none !important; }
  body { background: #fff; }
  .layout { display: block; padding: 0; }
  .content { background: #fff; }
}
