/* Fourth Offset inspired navigation (clean + minimal)
   - Homepage: vertical section map rail (no horizontal screen-spanning lines)
     * Labels stay hidden until hover/focus (expands on hover)
     * No heavy black focus bar
   - Layer pages: no extra expanding rail; only the main layer sidebar.
*/

:root {
  --map-left: 22px;
  --map-width: 260px;
  --map-top: 36px;
  --map-bottom: 36px;
}

/* ========== Homepage section map ========== */
.side-map {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--map-width);
  height: 100vh;
  pointer-events: none;
  z-index: 8;
}

/* Vertical rail */
.side-map::before {
  content: "";
  position: absolute;
  left: var(--map-left);
  top: var(--map-top);
  height: calc(100vh - var(--map-top) - var(--map-bottom));
  width: 1px;
  background: rgba(0, 0, 0, 0.22);
}

.side-map__item {
  position: absolute;
  left: var(--map-left);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  pointer-events: auto;
  color: var(--color-text, #000);
  transform: translateY(-50%);
  outline: none;
}

/* Dot */
.side-map__dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background: rgba(255, 255, 255, 0.96);
  flex: 0 0 9px;
  margin-left: -4px; /* centers dot over rail */
}

/* Label (hidden until hover/focus) */
.side-map__label {
  font-family: var(--font-sans, system-ui);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text, #000);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.10);
  padding: 7px 10px;
  line-height: 1;
  white-space: nowrap;

  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease;
  pointer-events: none;
}

/* Expand on hover over the map region, or over a specific item */
.side-map:hover .side-map__label,
.side-map__item:hover .side-map__label,
.side-map__item:focus-visible .side-map__label {
  opacity: 1;
  transform: translateX(0);
}

/* Active section */
.side-map__item.is-active .side-map__dot {
  background: rgba(0, 0, 0, 0.88);
  border-color: rgba(0, 0, 0, 0.88);
}

.side-map__item.is-active .side-map__label {
  border-color: rgba(0, 0, 0, 0.35);
}

/* Accessible focus without the thick browser outline */
.side-map__item:focus { outline: none; }
.side-map__item:focus-visible .side-map__label {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.85);
}

@media (max-width: 900px) {
  .side-map { display: none; }
}

/* Ensure the homepage uses full width (avoid reserved sidebar spacing from older builds) */
.side-map + .content-wrapper {
  margin-left: 0 !important;
}

/* ========== Redesigned Layer Pages ========== */

/* Fixed header with navigation */
.layer-fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 100;
}

.header-back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans, system-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text, #000);
  text-decoration: none;
  transition: opacity 200ms ease;
}

.header-back-link:hover {
  opacity: 0.65;
}

.header-back-link svg {
  flex-shrink: 0;
}

/* Header actions group */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Export PDF button - subtle top right */
.header-export-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-family: var(--font-sans, system-ui);
  font-size: 12px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.55);
  text-decoration: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  background: transparent;
  transition: all 180ms ease;
}

.header-export-btn:hover {
  color: rgba(0, 0, 0, 0.85);
  border-color: rgba(0, 0, 0, 0.18);
  background: rgba(0, 0, 0, 0.02);
}

.header-export-btn svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* Hamburger toggle */
.header-sidebar-toggle {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.toggle-icon {
  width: 20px;
  height: 14px;
  position: relative;
  display: block;
}

.toggle-icon::before,
.toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-text, #000);
  transition: transform 250ms ease, top 250ms ease;
}

.toggle-icon::before {
  top: 0;
  box-shadow: 0 6px 0 var(--color-text, #000);
}

.toggle-icon::after {
  top: 12px;
}

body.sidebar-hidden .toggle-icon::before {
  top: 6px;
  transform: rotate(45deg);
  box-shadow: none;
}

body.sidebar-hidden .toggle-icon::after {
  top: 6px;
  transform: rotate(-45deg);
}

/* Main layout */
.layer-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 60px;
}

/* New elegant sidebar */
.layer-sidebar-new {
  width: 340px;
  flex-shrink: 0;
  background: #fafafa;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-hidden .layer-sidebar-new {
  transform: translateX(-100%);
}

.sidebar-inner {
  padding: 40px 32px;
}

/* Sidebar sections */
.sidebar-section {
  margin-bottom: 48px;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

/* Layer identity */
.sidebar-identity {
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.sidebar-layer-title {
  font-family: var(--font-serif, 'Cormorant Garamond', serif);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 12px 0;
  color: var(--color-text, #000);
}

.sidebar-layer-measure {
  font-family: var(--font-sans, system-ui);
  font-size: 13px;
  line-height: 1.6;
  color: rgba(0, 0, 0, 0.55);
  margin: 0;
}

/* Navigation grid */
.sidebar-nav {
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.sidebar-nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sidebar-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 14px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: #ffffff;
  text-decoration: none;
  transition: border-color 200ms ease, background 200ms ease;
  min-height: 80px;
}

.sidebar-nav-link:hover {
  border-color: rgba(0, 0, 0, 0.25);
  background: #ffffff;
}

.sidebar-nav-link--disabled {
  opacity: 0.25;
  pointer-events: none;
}

.nav-link-label {
  font-family: var(--font-sans, system-ui);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.45);
}

.nav-link-title {
  font-family: var(--font-serif, 'Cormorant Garamond', serif);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-text, #000);
}

/* Competitive ranking */
.sidebar-section-title {
  font-family: var(--font-sans, system-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.45);
  margin: 0 0 20px 0;
}

.ranking-scores {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 16px;
}

.score-item {
  opacity: 0.65;
}

.score-item--primary {
  opacity: 1;
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.score-country {
  font-family: var(--font-sans, system-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text, #000);
}

.score-value {
  font-family: var(--font-serif, 'Cormorant Garamond', serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
}

.score-value--us {
  color: var(--color-us, #2563eb);
}

.score-value--china {
  color: var(--color-china, #dc2626);
}

.score-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.score-bar--us {
  background: var(--color-us, #2563eb);
}

.score-bar--china {
  background: var(--color-china, #dc2626);
}

.ranking-note {
  font-family: var(--font-sans, system-ui);
  font-size: 11px;
  color: rgba(0, 0, 0, 0.40);
  margin: 0;
  font-style: italic;
}

/* Main content area */
.layer-content-new {
  flex: 1;
  min-width: 0;
  transition: margin-left 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-hidden .layer-content-new {
  margin-left: 0;
}

.layer-article {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 40px 120px;
}

.article-header {
  margin-bottom: 40px;
}

.article-title {
  font-family: var(--font-serif, 'Cormorant Garamond', serif);
  font-size: 42px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 12px 0;
  color: var(--color-text, #000);
}

.article-description {
  font-family: var(--font-sans, system-ui);
  font-size: 16px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.65);
  margin: 0;
  max-width: 720px;
}

/* Responsive */
@media (max-width: 1024px) {
  .layer-sidebar-new {
    width: 300px;
  }

  .sidebar-inner {
    padding: 32px 24px;
  }
}

@media (max-width: 768px) {
  .layer-sidebar-new {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    max-width: 340px;
    z-index: 90;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  }

  .layer-article {
    padding: 32px 24px 80px;
  }

  .article-title {
    font-size: 36px;
  }
}
