/* ============================================================
   Particle Metro — Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Noto+Sans+JP:wght@400;500;600;700;800;900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #F5F0E8;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #2C2C2C;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ---- Header ---- */
.header {
  text-align: center;
  padding: 28px 20px 8px;
  width: 100%;
}

.header h1 {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #2862B9;
  margin-bottom: 0;
}

/* ---- Controls Bar ---- */
.controls {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  flex-wrap: wrap;
  justify-content: center;
}

.controls label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.controls select {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  height: 40px;
  padding: 0 40px 0 12px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background: #FFFFFF;
  color: #334155;
  cursor: pointer;
  min-width: 280px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.controls select:hover {
  border-color: #94A3B8;
}

.controls select:focus {
  outline: none;
  border-color: #2B70EF;
  box-shadow: 0 0 0 2px rgba(43, 112, 239, 0.15);
}

.controls button {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  height: 40px;
  padding: 0 16px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #FFFFFF;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, border-color 0.15s;
}

.controls button:hover {
  background: #F9FAFB;
  border-color: #94A3B8;
}

/* ---- Language Bar (top-right) ---- */
.lang-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 100;
}

.lang-flag {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  opacity: 0.5;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.lang-flag svg {
  fill: none;
}

.lang-flag:hover {
  opacity: 0.85;
  transform: scale(1.08);
}

.lang-flag.active {
  opacity: 1;
  box-shadow: 0 0 0 2px #2B70EF, 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ---- Process Share Buttons (inline, below decay-info) ---- */
.process-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px 6px;
  animation: fadeIn 0.3s ease;
}

.process-share[hidden] {
  display: none;
}

.process-share-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94A3B8;
  letter-spacing: 0.03em;
}

.sns-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.sns-btn svg {
  fill: #fff;
}

.sns-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.sns-twitter {
  background: #000;
}

.sns-facebook {
  background: #1877F2;
}

.sns-line {
  background: #06C755;
}

/* Share with video button (Web Share API) */
.share-video-btn {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #2B70EF;
  border-radius: 16px;
  background: #2B70EF;
  color: #FFFFFF;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.share-video-btn::before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8'/%3E%3Cpolyline points='16 6 12 2 8 6'/%3E%3Cline x1='12' y1='2' x2='12' y2='15'/%3E%3C/svg%3E") no-repeat center / contain;
}

.share-video-btn:hover {
  background: #1D5CC7;
  box-shadow: 0 2px 8px rgba(43, 112, 239, 0.3);
}

.share-video-btn[hidden] {
  display: none;
}

/* Download video button */
.download-btn {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  background: #FFFFFF;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.download-btn::before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E") no-repeat center / contain;
}

.download-btn:hover {
  background: #F0F7FF;
  border-color: #2B70EF;
  color: #2B70EF;
}

.download-btn:hover::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232B70EF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
}

/* ---- Decay Info ---- */
.decay-info {
  text-align: center;
  font-size: 0.8125rem;
  color: #64748B;
  padding: 0 20px 4px;
  min-height: 20px;
  max-width: 700px;
  line-height: 1.6;
  margin: 0 auto;
}

/* ---- Feynman Diagram Panel (absolute overlay, bottom-left of map) ---- */
.feynman-panel {
  position: absolute;
  bottom: 4%;
  left: 1.5%;
  width: 40%;
  max-width: 520px;
  min-width: 260px;
  z-index: 10;
  animation: fadeIn 0.3s ease;
  pointer-events: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.feynman-inner {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 14px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.feynman-title {
  font-size: 1.44rem;
  font-weight: 600;
  color: #64748B;
  letter-spacing: 0.03em;
  text-align: center;
  margin: 0;
}

.feynman-desc {
  font-size: 0.72rem;
  color: #8896A6;
  text-align: center;
  line-height: 1.5;
  margin: 0;
  padding: 0 8px;
}

.feynman-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

/* ---- Map Container ---- */
.map-container {
  position: relative;
  width: 100%;
  max-width: 1400px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px 30px;
  overflow: hidden;
}

.map-container svg {
  width: 100%;
  height: auto;
  max-height: 80vh;
}

/* ---- Station hover ---- */
.station {
  transition: transform 0.15s ease;
}

.station:hover circle:first-child {
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.2));
}

/* ---- Popup ---- */
.popup-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(2px);
}

.popup-overlay.visible {
  display: flex;
}

.popup-card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  position: relative;
  animation: popupIn 0.25s ease-out;
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.popup-symbol {
  font-size: 1.8rem;
  font-weight: 800;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #CCC;
  border-radius: 12px;
  background: #FAFAFA;
  flex-shrink: 0;
}

.popup-name {
  font-size: 1.4rem;
  font-weight: 700;
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #AAA;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}

.popup-close:hover {
  color: #555;
}

.popup-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.popup-table td {
  padding: 5px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid #F0F0F0;
}

.popup-table td:first-child {
  font-weight: 600;
  color: #888;
  width: 40%;
}

.popup-table td:last-child {
  color: #2C2C2C;
}

.popup-description {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.5;
  font-style: italic;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 10px 20px 20px;
  font-size: 0.72rem;
  color: #AAA;
}

/* ---- Zoom Controls ---- */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  color: #334155;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  transition: background-color 0.15s, border-color 0.15s;
  line-height: 1;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

.zoom-btn:hover {
  background: #F0F7FF;
  border-color: #2B70EF;
}

.zoom-btn:active {
  background: #E0ECFF;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .header {
    padding: 12px 12px 6px;
  }

  .header h1 {
    font-size: 1.2rem;
    padding-right: 80px;
  }

  .controls select {
    min-width: 200px;
  }

  .popup-card {
    padding: 20px 24px;
  }

  .lang-bar {
    top: 10px;
    right: 10px;
    gap: 6px;
  }

  .lang-flag {
    width: 34px;
    height: 34px;
  }

  .lang-flag svg {
    width: 18px;
    height: auto;
  }

  /* -- Button fixes -- */
  .process-share {
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 12px 6px;
  }

  .share-video-btn,
  .download-btn {
    font-size: 0.68rem;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0 10px;
    height: 28px;
  }

  .sns-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .sns-btn svg {
    width: 13px;
    height: 13px;
  }

  .process-share-label {
    font-size: 0.65rem;
    width: 100%;
    text-align: center;
    order: -1;
  }

  /* -- Map container: stack vertically -- */
  .map-container {
    flex-direction: column;
    align-items: stretch;
    padding: 4px 0 16px;
    flex: 0 0 auto;
  }

  .map-container svg {
    max-height: none;
    width: 100%;
    order: 1;
  }

  /* -- Feynman panel: full-width below map -- */
  .feynman-panel {
    position: static;
    width: 100%;
    max-width: 100%;
    min-width: unset;
    order: 2;
    pointer-events: auto;
    padding: 8px 12px 0;
  }

  .feynman-inner {
    border-radius: 8px;
  }

  /* -- Zoom controls on mobile -- */
  .zoom-controls {
    bottom: 10px;
    right: 10px;
  }

  .zoom-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
}
