/* =========================
   STYLES FOR ROAD MAINTENANCE REVIEW SITE
   ========================= */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next/AtkinsonHyperlegibleNext-VariableFont_wght.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf") format("truetype");
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg-light: #f6f7f8;
  --bg-white: #ffffff;
  --primary: #001459;
  --secondary: #A3AF31;
  --text-dark: #1f2933;
  --text-muted: #6b7280;
  --border-light: #e5e7eb;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible Next", sans-serif;
  color: var(--text-dark);
  background-color: var(--bg-light);
  line-height: 1.5;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid rgba(163, 175, 49, 0.95);
  outline-offset: 3px;
}

.page {
  display: grid;
  grid-template-columns: 460px 1fr;
  min-height: 100vh;
}

.sidebar {
  background-color: #F3F6F9;
  border-right: 1px solid var(--border-light);
  padding: 1.8rem;
  overflow-y: auto;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hero-img {
  width: 75%;
  margin-bottom: 16px;
  object-fit: contain;
}

.sidebar-header {
  margin-bottom: 2rem;
}

.sidebar-header h1 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem 0;
}

.sidebar-header p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0;
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0 0 2rem 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}

.sidebar-footer-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-footer-link:hover,
.sidebar-footer-link:focus-visible {
  color: var(--primary);
  text-decoration: underline;
}

.topic-list li {
  margin-bottom: 0.75rem;
}

.topic-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background-color: var(--bg-white);
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
}

.topic-button:hover {
  border-color: var(--primary);
}

.topic-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--secondary);
  color: #000;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.is-dropdown .dropdown-icon {
  margin-left: auto;
  transition: transform 0.2s;
}

.is-dropdown.open .dropdown-icon {
  transform: rotate(180deg);
}

.dropdown-list {
  list-style: none;
  padding: 0.25rem 0 0.75rem 2.2rem;
  margin: 0;
  display: none;
}

.is-dropdown.open .dropdown-list {
  display: block;
}

.dropdown-item {
  background: none;
  border: none;
  padding: 0.4rem 0;
  text-align: left;
  color: #000000;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
}

.dropdown-item:hover {
  text-decoration: underline;
}

.map-area {
  padding: 1.1rem;
  position: relative;
}

.info-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(163, 175, 49, 0.16), transparent 28%),
    linear-gradient(180deg, #f3f6f9 0%, #eef2f7 100%);
}

.info-page-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

.info-page-card {
  background: rgba(255,255,255,0.96);
  border-radius: 18px;
  padding: 2.5rem;
  box-shadow: 0 18px 48px rgba(0, 20, 89, 0.12);
}

.info-page-card h1,
.info-page-card h2 {
  color: var(--primary);
}

.info-page-card h1 {
  margin-top: 0.4rem;
  margin-bottom: 1rem;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.info-page-card h2 {
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.info-page-card p,
.info-page-card li {
  font-size: 1rem;
}

.info-page-backlink {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.info-page-backlink:hover {
  text-decoration: underline;
}

.map-wrapper {
  position: relative;
  background-color: var(--bg-white);
  border-radius: 10px;
  height: calc(100vh - 2.2rem);
  height: calc(100dvh - 2.2rem);
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

  #leaflet-map {
    width: 100%;
    height: 100%;
  }

  .map-reset-control {
    margin-top: 10px;
  }

  .map-reset-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--primary) !important;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    background: #fff;
  }

  .map-reset-button:hover,
  .map-reset-button:focus-visible {
    background: #f3f6f9;
    text-decoration: none;
  }

  .map-fullscreen-button {
    position: absolute;
    right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  border: 1px solid rgba(0, 20, 89, 0.15);
  border-radius: 12px;
  background: rgba(255,255,255,0.95);
  color: var(--primary);
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 2px 12px rgba(0,0,0,0.16);
  cursor: pointer;
}

.map-fullscreen-button:hover {
  border-color: rgba(0, 20, 89, 0.35);
}

.map-wrapper.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 4000;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  border-radius: 0;
}

body.map-fullscreen {
  overflow: hidden;
}

.map-wrapper.is-fullscreen .custom-layer-control {
  bottom: 1.25rem;
}

.leaflet-popup.rakentaminen-hover-popup {
  pointer-events: none;
}

  .custom-layer-control {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 1000;
  background: rgba(255,255,255,0.95);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    min-width: 180px;
    width: min(18rem, calc(100% - 5.5rem));
  }

  .control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .control-title {
    font-size: 0.75rem;
    font-weight: 800;
    display: block;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .control-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(0, 20, 89, 0.12);
    border-radius: 999px;
    background: #fff;
    color: var(--primary);
    padding: 0.35rem 0.65rem;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
  }

  .control-toggle:hover {
    border-color: rgba(0, 20, 89, 0.35);
  }

  .control-toggle-icon {
    transition: transform 0.2s ease;
  }

  .control-body {
    margin-top: 0.75rem;
  }

  .custom-layer-control[data-collapsed="true"] .control-body {
    display: none;
  }

  .custom-layer-control[data-collapsed="true"] .control-toggle-icon {
    transform: rotate(-180deg);
  }

  .layer-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  line-height: 1.25;
  cursor: pointer;
}

.layer-option input {
  margin: 0.15rem 0 0;
  flex: 0 0 auto;
}

.layer-option-label {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.layer-divider {
  border: 0;
  border-top: 1px solid #ddd;
  margin: 8px 0;
}

/* MODAL STYLES */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 2000;
  padding: 2rem;
}

.modal.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  position: relative;
  background: var(--bg-white);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  padding: 2.5rem 2.5rem 0;
  border-radius: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

#modalBody {
  padding-bottom: 1rem;
}

#modalBody img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.3rem 0;
}

img.can-zoom {
  cursor: zoom-in;
  transition: transform 0.2s;
}

img.can-zoom:hover {
  transform: scale(1.01);
}

img.can-zoom:focus-visible {
  outline: 3px solid rgba(163, 175, 49, 0.95);
  outline-offset: 4px;
}

.modal-close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(0,20,89,0.2);
  border-radius: 8px;
  font-size: 1.7rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  z-index: 3100;
  opacity: 0.8;
  transition: opacity 0.15s, border-color 0.15s, transform 0.15s;
}

.modal-close:hover {
  border-color: rgba(0,20,89,0.4);
  opacity: 1;
  transform: scale(1.03);
}

.modal-footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  position: sticky;
  bottom: 0;
  margin: 1.5rem -2.5rem 0;
  padding: 1.1rem 2.5rem 1.35rem;
  background: linear-gradient(180deg, rgba(247, 249, 252, 0.94) 0%, #f2f5fa 100%);
  border-top: 1px solid rgba(0, 20, 89, 0.08);
  box-shadow: 0 -10px 24px rgba(0, 20, 89, 0.08);
  z-index: 5;
}

.modal-footer-actions .next-chapter {
  margin-top: 0;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0;
  justify-content: center;
  border: none;
  box-shadow: 0 8px 18px rgba(0, 20, 89, 0.16);
  font-size: 2rem;
  line-height: 1;
}

.modal-share {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  cursor: pointer;
}

.modal-share:hover {
  border-color: var(--primary);
}

.modal-share[data-state="ok"] {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #111;
}

/* LIGHTBOX STYLES */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.94);
  display: none;
  z-index: 3000;
  align-items: center;
  justify-content: center;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-img-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  background: transparent;
  border: 0;
  color: white;
  font-size: 3rem;
  cursor: pointer;
  line-height: 1;
  z-index: 3100;
}

/* Lightbox navigation arrows */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  width: 60px;
  height: 60px;
  font-size: 2rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 3100;
}

.lb-nav:hover {
  background: rgba(255,255,255,0.25);
}

.lb-prev {
  left: -80px;
}

.lb-next {
  right: -80px;
}

@media (max-width: 1100px) {
  .lb-prev {
    left: 10px;
  }
  .lb-next {
    right: 10px;
  }
}

/* ARTICLE STYLES */
.modal-article {
  line-height: 1.7;
  color: var(--text-dark);
}

.article-hero {
  width: calc(100% + 5rem);
  margin: -2.5rem -2.5rem 2rem -2.5rem;
  min-height: 220px;
  background-color: var(--primary);
  background-image: linear-gradient(rgba(0,20,89,0.4), rgba(0,20,89,0.4)), var(--article-hero-image, url('img/vt4.jpg'));
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 2rem;
}

.article-hero h2 {
  color: white;
  margin: 0;
  font-size: 2.2rem;
  hyphens: auto;
  overflow-wrap: anywhere;
  word-break: normal;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.modal-article h3 {
  hyphens: auto;
  overflow-wrap: anywhere;
  word-break: normal;
}

.modal-article .lead {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--secondary);
  padding-left: 1.2rem;
}

.info-box {
  background-color: #F3F6F9;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
  border-top: 4px solid var(--primary);
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.info-box h4 {
  margin-top: 0;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.divider {
  height: 1px;
  background: linear-gradient(to right, var(--secondary), transparent);
  border: none;
  margin: 2.5rem 0;
}

.modal-article figure {
  margin: 1rem 0;
  padding: 0.5rem;
  border-radius: 8px;
}

.thumbnail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.thumbnail-gallery figure {
  margin: 0;
  padding: 0.75rem;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--border-light);
}

.thumbnail-gallery img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.map-preview-figure {
  max-width: 760px;
  margin: 1rem auto 1.5rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--border-light);
}

.inline-portrait-figure {
  max-width: 340px;
  margin: 1.5rem auto 0;
  padding: 0.75rem;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--border-light);
}

.inline-portrait-figure img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.map-preview-image {
  display: block;
  width: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

.modal-article figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
  font-style: italic;
}

.next-chapter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 0.8rem 1.5rem;
  background-color: var(--primary);
  color: white !important;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.2s;
}

.next-chapter:hover {
  background-color: var(--secondary);
  color: black !important;
}

@media (max-width: 900px) {
  .page {
    display: block;
  }
  .sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }

  .sidebar-footer {
    margin-top: 0;
  }
  .map-wrapper {
    height: 60vh;
  }

  .modal {
    padding: 1rem;
  }

  .modal-content {
    padding: 1.25rem 1.25rem 0;
  }

  .article-hero {
    width: calc(100% + 2.5rem);
    margin: -1.25rem -1.25rem 1.25rem -1.25rem;
    min-height: 180px;
    padding: 1.25rem;
  }

  .article-hero h2 {
    font-size: 1.7rem;
  }

  .modal-footer-actions {
    margin: 1.25rem -1.25rem 0;
    padding: 1rem 1.25rem 1.15rem;
    gap: 0.75rem;
  }

  .modal-footer-actions .next-chapter {
    width: 3rem;
    height: 3rem;
    font-size: 1.8rem;
  }

  .map-fullscreen-button {
    bottom: 1rem;
    right: 1rem;
  }

  .map-wrapper.is-fullscreen .custom-layer-control {
    max-width: min(280px, calc(100vw - 2rem));
    max-width: min(280px, calc(100dvw - 2rem));
  }

  .info-page-shell {
    padding: 1.25rem;
  }

  .info-page-card {
    padding: 1.5rem;
    border-radius: 14px;
  }
}
