/* Plateau Demo Styles — Professional full-window GIS application */

/* === Demo Header === */
.demo-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 48px;
  background: var(--ink, #123b37);
  border-bottom: 2px solid var(--teal, #157d6b);
  display: flex;
  align-items: center;
}

.demo-header-inner {
  width: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--white, #fff);
  font-weight: 700;
  font-size: 14px;
}

.demo-brand .brand-mark {
  color: var(--teal, #157d6b);
}

.demo-brand-label {
  white-space: nowrap;
}

.demo-poc-tag {
  font-size: 10px;
  font-weight: 600;
  background: var(--teal, #157d6b);
  color: var(--white, #fff);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

/* Sidebar toggle (mobile) */
.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white, #fff);
  width: 44px;
  height: 44px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.sidebar-toggle-icon,
.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.2s;
}

.sidebar-toggle-icon {
  background: transparent;
}

.sidebar-toggle-icon::before {
  content: "";
  transform: translate(-50%, -9px);
}

.sidebar-toggle-icon::after {
  content: "";
  transform: translate(-50%, 9px);
}

/* === Layout === */
.demo-layout {
  display: flex;
  margin-top: 48px;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* === Sidebar === */
.demo-sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--off-white, #f5f7f3);
  border-right: 1px solid var(--gray-200, #e0e0e0);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.demo-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--teal, #157d6b);
  padding: 12px 16px 4px;
  margin: 0;
  text-transform: uppercase;
}

/* Search */
.demo-search {
  padding: 8px 16px 16px;
  border-bottom: 1px solid var(--gray-200, #e0e0e0);
}

.demo-search-row {
  margin-bottom: 8px;
}

.demo-search-row select {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-jp, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif);
  border: 1px solid var(--gray-200, #e0e0e0);
  border-radius: 4px;
  background: var(--white, #fff);
  color: var(--ink, #123b37);
  min-height: 44px;
}

.demo-search-row select:focus {
  outline: 2px solid var(--teal, #157d6b);
  outline-offset: 1px;
}

/* Buttons */
.demo-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-jp, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-height: 44px;
  text-align: center;
}

.demo-btn-primary {
  background: var(--teal, #157d6b);
  color: var(--white, #fff);
}

.demo-btn-primary:hover {
  background: var(--teal-dark, #0f5c50);
}

.demo-btn-secondary {
  background: var(--white, #fff);
  color: var(--teal, #157d6b);
  border: 1px solid var(--teal, #157d6b);
}

.demo-btn-secondary:hover {
  background: var(--pale-mint, #e8f5f0);
}

/* Dataset List */
.demo-datasets {
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--gray-200, #e0e0e0);
  flex-shrink: 0;
}

.dataset-list {
  max-height: 240px;
  overflow-y: auto;
  margin: 8px 0;
}

.dataset-item {
  padding: 8px 10px;
  border: 1px solid var(--gray-200, #e0e0e0);
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  background: var(--white, #fff);
  transition: border-color 0.15s, background 0.15s;
}

.dataset-item:hover {
  border-color: var(--teal, #157d6b);
}

.dataset-item.selected {
  border-color: var(--teal, #157d6b);
  background: var(--pale-mint, #e8f5f0);
}

.dataset-item:focus-visible {
  outline: 2px solid var(--teal, #157d6b);
  outline-offset: 1px;
}

.dataset-label {
  font-size: 13px;
  line-height: 1.5;
}

.dataset-label strong {
  display: block;
  font-size: 13px;
}

.dataset-city, .dataset-year, .dataset-format, .dataset-lod {
  display: inline-block;
  font-size: 11px;
  color: var(--gray-600, #666);
  margin-right: 6px;
}

.dataset-format {
  background: var(--lime, #d6ed85);
  color: var(--ink, #123b37);
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 600;
}

.empty-msg {
  font-size: 13px;
  color: var(--gray-600, #666);
  padding: 12px 0;
  text-align: center;
}

/* Overlays */
.demo-overlays {
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--gray-200, #e0e0e0);
}

.overlay-list {
  margin: 8px 0;
}

.overlay-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  cursor: pointer;
}

.overlay-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal, #157d6b);
  cursor: pointer;
}

.overlay-empty {
  font-size: 13px;
  color: var(--gray-600, #666);
  padding: 8px 0;
  font-style: italic;
}

/* Metadata */
.demo-metadata {
  padding: 0 16px 16px;
  flex: 1;
  min-height: 0;
}

.metadata-drawer {
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink, #123b37);
}

.metadata-drawer p {
  margin: 2px 0;
}

.metadata-drawer a {
  color: var(--teal, #157d6b);
  word-break: break-all;
}

.metadata-empty {
  color: var(--gray-600, #666);
  font-style: italic;
}

/* === Main Map Area === */
.demo-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Mode Toggle */
.demo-mode-toggle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  border: 1px solid var(--gray-200, #e0e0e0);
  border-radius: 4px;
  overflow: hidden;
  background: var(--white, #fff);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mode-btn {
  padding: 8px 24px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-jp, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif);
  background: var(--white, #fff);
  border: none;
  cursor: pointer;
  color: var(--gray-600, #666);
  min-height: 44px;
  min-width: 60px;
  transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
  background: var(--teal, #157d6b);
  color: var(--white, #fff);
}

.mode-btn:not(:last-child) {
  border-right: 1px solid var(--gray-200, #e0e0e0);
}

.mode-btn:focus-visible {
  outline: 2px solid var(--teal, #157d6b);
  outline-offset: -2px;
}

/* Map Containers */
.map-container,
.cesium-container {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  position: relative;
}

.map-container {
  background: var(--off-white, #f5f7f3);
}

.cesium-container {
  background: #000;
}

/* Cesium overrides */
.cesium-container .cesium-viewer {
  height: 100%;
  width: 100%;
}

.cesium-container .cesium-widget-credits {
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.5);
}

.cesium-container .cesium-widget-credits a {
  color: rgba(255,255,255,0.9);
}

/* OL Popup */
.ol-popup {
  position: absolute;
  background: var(--white, #fff);
  border: 1px solid var(--gray-200, #e0e0e0);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  max-width: 240px;
  display: none;
}

.ol-popup:has(.popup-content:not(:empty)) {
  display: block;
}

.popup-content {
  font-family: var(--font-jp, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif);
}

.popup-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-source a {
  color: var(--teal, #157d6b);
  font-size: 11px;
}

/* Status Bar */
.demo-status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--gray-200, #e0e0e0);
  font-size: 12px;
}

.demo-status {
  color: var(--ink, #123b37);
  font-weight: 500;
}

.demo-status.ok { color: var(--teal, #157d6b); }
.demo-status.error { color: #c0392b; }
.demo-status.warning { color: #e67e22; }
.demo-status.stale { color: #e67e22; }
.demo-status.info { color: var(--gray-600, #666); }

.layer-counts {
  color: var(--gray-600, #666);
  font-size: 11px;
}

.dataset-error {
  color: #c0392b;
  font-size: 11px;
  font-weight: 600;
}

.demo-loading {
  color: var(--teal, #157d6b);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--teal, #157d6b);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.demo-error {
  color: #c0392b;
  font-weight: 600;
}

/* === Screen Reader Only === */
.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;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: block;
  }

  .demo-sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    width: 300px;
    min-width: 300px;
    z-index: 500;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .demo-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0,0,0,0.2);
  }

  .demo-layout {
    flex-direction: column;
  }

  .demo-main {
    min-height: 50vh;
  }

  .mode-btn {
    padding: 8px 16px;
    min-width: 48px;
  }

  .demo-mode-toggle {
    top: 8px;
  }
}

@media (max-width: 480px) {
  .demo-header {
    height: 44px;
  }

  .demo-layout {
    margin-top: 44px;
    height: calc(100vh - 44px);
  }

  .demo-sidebar {
    top: 44px;
    width: 280px;
  }

  .demo-brand-label {
    font-size: 13px;
  }

  .demo-poc-tag {
    display: none;
  }
}

/* Live data, attribution, and accessible mobile controls. */
[hidden] { display: none !important; }
.demo-main { min-height: 0; }
.demo-search-row label { display: block; margin-bottom: 3px; font-size: 12px; font-weight: 600; color: var(--ink, #123b37); }
.dataset-item { display: block; width: 100%; text-align: left; font-family: inherit; color: var(--ink, #123b37); }
.dataset-detail { display: block; margin-top: 4px; font-size: 11px; color: var(--gray-600, #4c5954); }
.overlay-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; }
.overlay-item label { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.overlay-refresh { min-height: 36px; padding: 4px 10px; background: #fff; color: var(--ink, #123b37); border: 1px solid var(--gray-200, #e0e0e0); border-radius: 4px; cursor: pointer; }
.overlay-refresh:focus-visible, .overlay-item input:focus-visible { outline: 2px solid var(--teal, #157d6b); outline-offset: 2px; }
.demo-status-bar { position: relative; inset: auto; left: auto; right: auto; bottom: auto; z-index: auto; flex: 0 0 auto; }
.catalog-stale { padding: 4px 8px; color: #71420e; background: #fff2cf; border-left: 3px solid #bd7d20; }
.map-credits { color: var(--gray-600, #4c5954); font-size: 10px; line-height: 1.5; }
.map-credits a { color: #075b50; text-underline-offset: 2px; }
.demo-status-bar a:focus-visible { outline: 2px solid var(--teal, #157d6b); outline-offset: 2px; }
#popup[aria-hidden="true"] { display: none; }
#popup[aria-hidden="false"] { display: block; }

@media (max-width: 768px) {
  .demo-sidebar { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .demo-status-bar { max-height: 112px; overflow-y: auto; }
}

.context-notice{padding:12px 16px;background:#fff5d9;color:#684c10;font-size:12px;line-height:1.7;margin:0}

.demo-status-bar .demo-status{display:block;padding:0;margin:0;border:0;border-radius:0;background:none;font-size:12px;line-height:1.6}

/* External viewer stays separate from GIS editing controls. */
.demo-reearth-link { margin-left:auto; max-width:132px; color:#fff; font-size:12px; line-height:1.3; text-underline-offset:3px; }
@media(max-width:360px) { .demo-brand-label { font-size:11px; } .demo-header-inner { gap:8px; padding:0 10px; } .demo-reearth-link { font-size:11px; } }
