:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e5e7eb;
  --radius: 10px;
  --max-width: 960px;
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* -------- Header -------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 600;
}

.site-brand:hover {
  text-decoration: none;
}

.site-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  background: #f3f4f6;
}

.site-title {
  font-size: 1.15rem;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text);
}

/* -------- Header search -------- */
.site-search {
  position: relative;
  flex: 1 1 200px;
  max-width: 260px;
  margin-left: auto;
}

.site-search-input {
  width: 100%;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f9fafb;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.site-search-input:focus {
  border-color: var(--accent);
  background: #fff;
}

.site-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
}

.site-search-results li a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-radius: 6px;
}

.site-search-results li a:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.site-search-results li strong {
  display: block;
  font-size: 0.9rem;
}

.site-search-results li span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-search-empty {
  padding: 0.6rem 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* -------- Main -------- */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.page-title {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.page-subtitle {
  color: var(--muted);
  margin: 0 0 2rem;
}

/* -------- Home: feature list -------- */
.feature-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.feature-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: inherit;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.feature-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.feature-card h3 {
  margin: 0 0 0.4rem;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
}

.feature-card img {
  display: block;
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  /* Prevents the image from overflowing small screens */
  height: auto;
}

/* -------- Story / feature templates -------- */
.story {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.story h1 {
  margin-top: 0;
}

.story-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.story p {
  margin: 1rem 0;
}

.story figure {
  margin: 1.5rem 0;
}

figure img {
  margin-inline: auto;
}

.story figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 0.5rem;
}

.media-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin: 1.5rem 0;
}

.media-grid img {
  border-radius: var(--radius);
}

/* Responsive 16:9 video container (works for <iframe> or <video>) */
.video-wrap {
  position: relative;
  padding-top: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1.5rem 0;
  background: #000;
}

.video-wrap iframe,
.video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* -------- Home sections -------- */
.home-section {
  margin-top: 2.5rem;
}

.section-title {
  font-size: 0.85rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.empty-note {
  color: var(--muted);
  font-size: 0.95rem;
}

/* -------- Carousel -------- */
.carousel {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f3f4f6;
  margin: 2rem 0 0;
}

.carousel-viewport {
  overflow: hidden;
}

.carousel-track {
  display: flex;
  transition: transform 0.5s ease;
  will-change: transform;
}

.carousel-slide {
  flex: 0 0 100%;
  min-width: 0;
}

.carousel-slide img {
  width: 100%;
  height: 480px;
  object-fit: cover;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.carousel-btn:hover {
  background: #fff;
}

.carousel-prev {
  left: 0.75rem;
}

.carousel-next {
  right: 0.75rem;
}

.carousel-dots {
  position: absolute;
  bottom: 0.75rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 0;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.carousel-dot:hover {
  background: rgba(255, 255, 255, 0.9);
}

.carousel-dot.is-active {
  background: #fff;
  transform: scale(1.2);
}

.carousel-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

/* -------- Lightbox -------- */
.story img.is-zoomable {
  cursor: zoom-in;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: grid;
  place-items: center;
  padding: 2rem;
  z-index: 1000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  margin: 0;
  max-width: min(1200px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lightbox-img {
  max-width: 100%;
  max-height: calc(100vh - 6rem);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.85;
  max-width: 60ch;
}

.lightbox-caption[hidden] {
  display: none;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
}

.lightbox-prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

/* -------- Footer -------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.back-to-top {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.back-to-top:hover {
  background: var(--accent-hover);
}

.random-feature-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.random-feature-btn:hover {
  background: var(--accent);
  color: #fff;
}

.random-feature-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.to-contents-btn {
  background: transparent;
  border: 1px solid var(--accent);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.to-contents-btn:hover {
  color: #fc0000;
}

.copyright {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

/* -------- Battalion tables (used by features/battalions/*.html) -------- */
.w3-table,
.w3-table-all {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  display: table;
}

.w3-table-all {
  border: 1px solid #ccc;
}

.w3-bordered tr,
.w3-table-all tr {
  border-bottom: 1px solid #ddd;
}

.w3-table-all tr:nth-child(odd) {
  background-color: #fff;
}

.w3-table-all tr:nth-child(even) {
  background-color: #f1f1f1;
}

.w3-hoverable tbody tr:hover,
.w3-ul.w3-hoverable li:hover {
  background-color: #ccc;
}

.w3-table td,
.w3-table th,
.w3-table-all td,
.w3-table-all th {
  padding: 8px 8px;
  display: table-cell;
  text-align: left;
  vertical-align: top;
}

.w3-table th:first-child,
.w3-table td:first-child,
.w3-table-all th:first-child,
.w3-table-all td:first-child {
  padding-left: 16px;
}

/* -------- Data table (dense, wide) --------
   Used by features/templates/example-data-table.html.
   For large datasets (thousands of rows): smaller text, tighter
   padding, and a page that widens beyond the normal .site-main column
   so more columns fit. Rows wrap instead of forcing a horizontal
   scrollbar — a bottom scrollbar on a data table reads as "the page
   is broken", not "scroll to see more" — and pagination (below) keeps
   the number of <tr> elements on screen at once manageable so the
   page itself doesn't get unreasonably long. The header row uses
   position: sticky so it stays visible while scrolling; --header-height
   is measured from the real .site-header by syncHeaderHeightVar() in
   /js/main.js so it lines up under the sticky site header rather than
   being hidden behind it. */
:root {
  --header-height: 65px;
}

.site-main--wide {
  max-width: 1400px;
}

.table-scroll {
  overflow-x: auto;
  margin: 1.5rem 0;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  min-width: 900px;
  margin: 0;
  font-size: 0.75rem;
}

.data-table th,
.data-table td {
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  overflow-wrap: break-word;
}

.data-table th:first-child,
.data-table td:first-child {
  padding-left: 12px;
}

.data-table thead th {
  position: sticky;
  top: var(--header-height);
  background: #f3f4f6;
  border-bottom: 1px solid #ccc;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.08);
  z-index: 1;
}

.data-table tbody tr:nth-child(even) {
  background-color: #f7f7f8;
}

.data-table tbody tr:hover {
  background-color: #e5e7eb;
}

.data-table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0 0;
}

.data-table-page-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.data-table-page-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

.data-table-page-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.data-table-page-info {
  color: var(--muted);
  font-size: 0.85rem;
}

/* -------- Modals -------- */
.openModal {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgb(0, 0, 0);
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background-color: #fefefe;
  margin: auto;
  padding: 0;
  border: 1px solid #888;
  width: 90%;
  box-shadow:
    0 4px 8px 0 rgba(0, 0, 0, 0.2),
    0 6px 20px 0 rgba(0, 0, 0, 0.19);
  -webkit-animation-name: animatetop;
  -webkit-animation-duration: 0.4s;
  animation-name: animatetop;
  animation-duration: 0.4s;
}

@-webkit-keyframes animatetop {
  from {
    top: -300px;
    opacity: 0;
  }

  to {
    top: 0;
    opacity: 1;
  }
}

@keyframes animatetop {
  from {
    top: -300px;
    opacity: 0;
  }

  to {
    top: 0;
    opacity: 1;
  }
}

.close {
  color: white;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

.modal-header {
  padding: 2px 8px;
  background-color: #fc4242;
  color: white;
}

.modal-body {
  padding: 2px 8px;
}

/* -------- Responsive -------- */
@media (max-width: 600px) {
  .site-header {
    padding: 0.75rem 1rem;
  }

  .site-nav {
    gap: 0.9rem;
  }

  .site-title {
    font-size: 1rem;
  }

  .site-search {
    flex-basis: 100%;
    max-width: none;
    margin-left: 0;
    order: 3;
  }

  .site-main {
    padding: 1.5rem 1rem;
  }

  .story {
    padding: 1.25rem;
  }

  .carousel-slide img {
    height: 220px;
  }

  .lightbox {
    padding: 1rem;
  }

  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
  }
}

/* ---- rest image ---*/

.portrait img {
  display: flex;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* --- centre ---*/
.center {
  margin-left: auto;
  margin-right: auto;
  display: block;
}
