/* =============================================
   赤土マップ「あかいや〜ん」共通スタイル
   モバイルファースト設計
   ============================================= */

/* --- CSS Variables --- */
:root {
  /* Colors */
  --color-primary: #d32f2f;
  --color-primary-dark: #b71c1c;
  --color-primary-light: #ff6659;
  --color-secondary: #1565c0;
  --color-secondary-light: #5e92f3;
  --color-accent: #ff8f00;
  --color-success: #2e7d32;
  --color-warning: #f9a825;
  --color-danger: #c62828;

  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-text: #212121;
  --color-text-secondary: #757575;
  --color-border: #e0e0e0;
  --color-overlay: rgba(0, 0, 0, 0.5);

  /* Severity Colors */
  --severity-1: #66bb6a;
  --severity-2: #ffee58;
  --severity-3: #ffa726;
  --severity-4: #ef5350;
  --severity-5: #b71c1c;

  /* Category Colors */
  --cat-sea: #0288d1;
  --cat-river: #00897b;
  --cat-mountain: #558b2f;

  /* Typography */
  --font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: clamp(0.625rem, 2vw, 0.75rem);
  --font-size-sm: clamp(0.75rem, 2.5vw, 0.875rem);
  --font-size-base: clamp(0.875rem, 3vw, 1rem);
  --font-size-lg: clamp(1rem, 3.5vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 4vw, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 5vw, 2rem);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);

  /* Layout */
  --nav-height: 60px;
  --bottom-nav-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
}

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

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

/* --- Top Header Bar --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  white-space: nowrap;
}

.header__subtitle {
  font-size: var(--font-size-xs);
  opacity: 0.8;
}

.header__actions {
  display: flex;
  gap: var(--space-sm);
}

/* --- Bottom Navigation (Mobile App-like) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
}

.bottom-nav__item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  color: var(--color-text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 20px;
  transition: all 0.2s;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item.active {
  color: #fff;
  background: var(--color-primary);
  font-weight: 700;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:active {
  background: var(--color-primary-dark);
  transform: scale(0.97);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.btn--success {
  background: var(--color-success);
  color: #fff;
}

.btn--full {
  width: 100%;
}

.btn--lg {
  padding: 16px 28px;
  font-size: var(--font-size-lg);
  border-radius: var(--radius-md);
}

.btn--fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  font-size: 28px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
}

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.card__body {
  padding: var(--space-md);
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s;
  min-height: 44px;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* --- Checkbox & Radio --- */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  min-height: 44px;
  cursor: pointer;
}

.form-check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

.form-check__label {
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

/* --- Selector Chips --- */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.chip {
  padding: 8px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  -webkit-tap-highlight-color: transparent;
}

.chip.selected {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.chip--sea.selected {
  background: var(--cat-sea);
  border-color: var(--cat-sea);
}

.chip--river.selected {
  background: var(--cat-river);
  border-color: var(--cat-river);
}

.chip--mountain.selected {
  background: var(--cat-mountain);
  border-color: var(--cat-mountain);
}

/* --- Severity Dots --- */
.severity-selector {
  display: flex;
  gap: var(--space-sm);
}

.severity-dot {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 3px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.severity-dot.selected {
  border-color: transparent;
  color: #fff;
  transform: scale(1.1);
}

.severity-dot[data-value="1"].selected {
  background: var(--severity-1);
}

.severity-dot[data-value="2"].selected {
  background: var(--severity-2);
  color: #333;
}

.severity-dot[data-value="3"].selected {
  background: var(--severity-3);
}

.severity-dot[data-value="4"].selected {
  background: var(--severity-4);
}

.severity-dot[data-value="5"].selected {
  background: var(--severity-5);
}

/* --- Slide-up Panel (Mobile) --- */
.slide-panel {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 900;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.slide-panel.open {
  transform: translateY(0);
}

.slide-panel__handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: var(--space-sm) auto var(--space-md);
}

.slide-panel__content {
  padding: 0 var(--space-md) var(--space-md);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 2000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal__header {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  z-index: 1;
}

.modal__close {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__body {
  padding: var(--space-md);
}

/* --- Tags --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.tag--sea {
  background: #e1f5fe;
  color: var(--cat-sea);
}

.tag--river {
  background: #e0f2f1;
  color: var(--cat-river);
}

.tag--mountain {
  background: #f1f8e9;
  color: var(--cat-mountain);
}

.tag--severity-1 {
  background: #e8f5e9;
  color: #2e7d32;
}

.tag--severity-2 {
  background: #fffde7;
  color: #f57f17;
}

.tag--severity-3 {
  background: #fff3e0;
  color: #e65100;
}

.tag--severity-4 {
  background: #fbe9e7;
  color: #bf360c;
}

.tag--severity-5 {
  background: #ffebee;
  color: #b71c1c;
}

/* --- Toast / Snackbar --- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(200px);
  background: #323232;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  transition: transform 0.3s ease;
  text-align: center;
  max-width: 90%;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

.text-center {
  text-align: center;
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mb-md {
  margin-bottom: var(--space-md);
}

/* =============================================
   Tablet & PC Responsive (min-width: 768px)
   ============================================= */
@media (min-width: 768px) {
  :root {
    --bottom-nav-height: 0px;
  }

  body {
    padding-bottom: 0;
  }

  .bottom-nav {
    display: none;
  }

  .header__nav {
    display: flex;
    gap: var(--space-md);
  }

  .header__nav a {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
  }

  .header__nav a:hover,
  .header__nav a.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
  }

  .modal-overlay.active {
    align-items: center;
  }

  .modal {
    border-radius: var(--radius-lg);
    max-width: 560px;
    max-height: 80vh;
  }

  .slide-panel {
    position: static;
    transform: none;
    box-shadow: none;
    border-radius: 0;
    max-height: none;
  }

  .btn--fab {
    display: none;
  }
}

/* =============================================
   PC (min-width: 1024px)
   ============================================= */
@media (min-width: 1024px) {
  .modal {
    max-width: 640px;
  }
}