/* ============================================
   CSS Reset & Base
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Roboto Serif", Georgia, "Times New Roman", serif;
  background-color: #f8f9fa;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

textarea {
  font-family: inherit;
  font-size: inherit;
}

h1, h2, h3 {
  font-weight: 600;
}

:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ============================================
   Layout
   ============================================ */

.container {
  max-width: 2040px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ============================================
   Nav Bar
   ============================================ */

.nav-bar {
  background-color: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 2040px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.nav-inner h1 {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

.nav-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.02em;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  transition: background-color 0.15s;
}

.nav-tab.active {
  background-color: #f3f4f6;
  color: #1a1a2e;
}

.nav-tab:not(.active):hover {
  background-color: #f9fafb;
}

/* ============================================
   Status Banner
   ============================================ */

.status-banner {
  --status-color: #9ca3af;
  --status-bg: rgba(156, 163, 175, 0.08);
  background-color: var(--status-bg);
  border: 1px solid #e5e7eb;
  padding: 20px 24px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--status-color);
  flex-shrink: 0;
}

.status-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--status-color);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
}

.status-avg {
  font-weight: 600;
  color: #1a1a2e;
}

.status-separator {
  color: #d1d5db;
}

.status-total {
  color: #6b7280;
}

/* Status color states */
.status-banner.status-blue   { --status-color: #3b82f6; --status-bg: rgba(59, 130, 246, 0.06); }
.status-banner.status-green  { --status-color: #16a34a; --status-bg: rgba(22, 163, 74, 0.06); }
.status-banner.status-yellow { --status-color: #ca8a04; --status-bg: rgba(202, 138, 4, 0.06); }
.status-banner.status-orange { --status-color: #ea580c; --status-bg: rgba(234, 88, 12, 0.06); }
.status-banner.status-red    { --status-color: #dc2626; --status-bg: rgba(220, 38, 38, 0.06); }
.status-banner.status-darkred { --status-color: #7c2d12; --status-bg: rgba(124, 45, 18, 0.06); }
.status-banner.status-gray   { --status-color: #9ca3af; --status-bg: rgba(156, 163, 175, 0.06); }

/* ============================================
   Vote Section
   ============================================ */

.vote-section {
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 28px 24px;
  margin-top: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.vote-heading {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 18px;
  color: #1a1a2e;
}

/* Star Rating */

.star-rating {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 16px;
  user-select: none;
}

.star-rating .star {
  font-size: 2.25rem;
  color: #d1d5db;
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
  line-height: 1;
}

.star-rating .star:hover,
.star-rating .star.hovered {
  color: #f59e0b;
  transform: scale(1.1);
}

.star-rating .star.selected {
  color: #f59e0b;
}

/* Category Pills */

.category-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pill {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
  color: #6b7280;
  transition: all 0.15s;
}

.pill:hover {
  border-color: #9ca3af;
  color: #374151;
}

.pill.active {
  border-color: #3b82f6;
  color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.06);
}

/* Comment Input */

.comment-input-wrap {
  position: relative;
  max-width: 480px;
  margin: 0 auto 16px;
}

.comment-input {
  width: 100%;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 0;
  padding: 10px 12px;
  color: #1a1a2e;
  resize: vertical;
  min-height: 52px;
  transition: border-color 0.15s;
}

.comment-input::placeholder {
  color: #9ca3af;
}

.comment-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.char-counter {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.75rem;
  color: #9ca3af;
  pointer-events: none;
}

.char-counter.warn {
  color: #ea580c;
}

.char-counter.limit {
  color: #dc2626;
}

/* Submit Button */

.submit-btn {
  padding: 10px 32px;
  border-radius: 8px;
  background-color: #3b82f6;
  color: #fff;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: background-color 0.15s, opacity 0.15s;
}

.submit-btn:hover {
  background-color: #2563eb;
}

.submit-btn:active {
  background-color: #1d4ed8;
}

.submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Feedback */

.feedback {
  margin-top: 12px;
  font-size: 0.875rem;
  min-height: 1.25em;
}

.feedback.success {
  color: #16a34a;
}

.feedback.error {
  color: #dc2626;
}

/* Vote section disabled state */

.vote-section.disabled {
  opacity: 0.5;
}

.vote-section.disabled .star,
.vote-section.disabled .pill,
.vote-section.disabled .comment-input,
.vote-section.disabled .submit-btn {
  pointer-events: none;
}

/* ============================================
   Chart Section
   ============================================ */

.chart-section {
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 20px 24px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* Period Selector */

.period-selector {
  display: flex;
  gap: 4px;
  background-color: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
}

.period-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.15s;
}

.period-btn:hover {
  color: #374151;
}

.period-btn.active {
  background-color: #fff;
  color: #1a1a2e;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Chart Labels */

.chart-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 20px;
}

.chart-label:first-of-type {
  margin-top: 0;
}

/* Chart Containers */

.chart-container {
  position: relative;
  width: 100%;
}

.chart-rating {
  height: 280px;
}

.chart-volume {
  height: 130px;
}

.chart-variance {
  height: 200px;
}

.chart-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #9ca3af;
  font-size: 0.875rem;
}

/* ============================================
   Variance Section
   ============================================ */

.variance-section {
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  margin-top: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.variance-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #6b7280;
  transition: color 0.15s;
}

.variance-toggle:hover {
  color: #374151;
}

.toggle-arrow {
  font-size: 0.75rem;
  transition: transform 0.25s;
}

.variance-section.expanded .toggle-arrow {
  transform: rotate(180deg);
}

.variance-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 24px;
}

.variance-section.expanded .variance-body {
  max-height: 500px;
  padding: 0 24px 20px;
}

/* ============================================
   Bottom Row
   ============================================ */

.bottom-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.bottom-col {
  flex: 1;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 20px 24px;
  min-width: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bottom-col:first-child {
  flex: 0 0 auto;
  max-width: 648px;
  width: 648px;
}

.section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1a1a2e;
}

/* Category Breakdown */

.category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.category-row:last-child {
  margin-bottom: 0;
}

.category-label {
  flex-shrink: 0;
  width: 90px;
  font-size: 0.8125rem;
  color: #6b7280;
  text-align: right;
}

.category-bar-bg {
  flex: 1;
  height: 8px;
  background-color: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  width: var(--pct, 0%);
  background-color: #3b82f6;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.category-pct {
  flex-shrink: 0;
  width: 36px;
  font-size: 0.8125rem;
  color: #6b7280;
  text-align: right;
}

/* Comments List */

#comments-list {
  max-height: 340px;
  overflow-y: auto;
}

.comment-item {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.comment-stars {
  display: inline-flex;
  gap: 1px;
}

.comment-stars .star {
  font-size: 0.8125rem;
  line-height: 1;
}

.comment-stars .star.filled {
  color: #f59e0b;
}

.comment-stars .star.empty {
  color: #d1d5db;
}

.comment-category {
  font-size: 0.75rem;
  color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.06);
  padding: 1px 8px;
  border-radius: 10px;
}

.comment-time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-left: auto;
}

.comment-text {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.4;
  word-break: break-word;
}

/* Screen-reader only (hidden SEO text) */

.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;
}

/* Muted helper text */

.muted {
  color: #9ca3af;
  font-size: 0.875rem;
}

/* Scrollbar styling for comments */

#comments-list::-webkit-scrollbar {
  width: 6px;
}

#comments-list::-webkit-scrollbar-track {
  background: transparent;
}

#comments-list::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}

/* ============================================
   Home Page: Ranking Cards
   ============================================ */

.ranking-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.ranking-card {
  display: block;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 20px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ranking-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.ranking-service {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.ranking-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ranking-card .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ranking-card.status-blue .status-dot { background: #3b82f6; }
.ranking-card.status-green .status-dot { background: #22c55e; }
.ranking-card.status-yellow .status-dot { background: #eab308; }
.ranking-card.status-orange .status-dot { background: #f97316; }
.ranking-card.status-red .status-dot { background: #ef4444; }
.ranking-card.status-darkred .status-dot { background: #7c2d12; }
.ranking-card.status-gray .status-dot { background: #9ca3af; }

.ranking-card.status-blue .ranking-status-text { color: #3b82f6; }
.ranking-card.status-green .ranking-status-text { color: #22c55e; }
.ranking-card.status-yellow .ranking-status-text { color: #a16207; }
.ranking-card.status-orange .ranking-status-text { color: #ea580c; }
.ranking-card.status-red .ranking-status-text { color: #ef4444; }
.ranking-card.status-darkred .ranking-status-text { color: #7c2d12; }
.ranking-card.status-gray .ranking-status-text { color: #9ca3af; }

.ranking-status-text {
  font-weight: 600;
  font-size: 0.9375rem;
}

.ranking-avg {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.ranking-total {
  font-size: 0.8125rem;
  color: #6b7280;
}

/* ============================================
   Home Page: Combined Chart
   ============================================ */

.chart-combined {
  min-height: 300px;
}

/* ============================================
   Home Page: Rant Wall
   ============================================ */

.rant-section {
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 20px 24px;
  margin-top: 16px;
}

.rant-section .section-title {
  margin-bottom: 16px;
}

.rant-form {
  margin-bottom: 20px;
}

.rant-input {
  display: block;
  width: 100%;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 0;
  padding: 10px 12px;
  color: #1a1a2e;
  resize: vertical;
  font-size: 0.9375rem;
  line-height: 1.5;
  min-height: 48px;
}

.rant-input:focus {
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.rant-form-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.rant-submit-btn {
  padding: 8px 24px;
  font-size: 0.875rem;
}

.rant-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rant-item {
  padding: 12px 0;
  border-top: 1px solid #f0f0f0;
}

.rant-item:first-child {
  border-top: 1px solid #e5e7eb;
}

.rant-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.rant-tag {
  font-family: monospace;
  font-size: 0.75rem;
  color: #6366f1;
  background: #f0f0ff;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
}

.rant-time {
  font-size: 0.75rem;
  color: #9ca3af;
}

.rant-text {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #1a1a2e;
  word-break: break-word;
}

/* ============================================
   Footer
   ============================================ */

.footer {
  text-align: center;
  padding: 24px 16px;
  color: #9ca3af;
  font-size: 0.8125rem;
  border-top: 1px solid #e5e7eb;
}

/* ============================================
   Sidebar Rankings (voting page)
   ============================================ */

.sidebar-rankings {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  z-index: 100;
  gap: 2px;
}

.sidebar-bar {
  width: 30px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: #9ca3af;
  transition: background 0.2s, width 0.15s;
}

.sidebar-bar:hover {
  width: 36px;
}

.sidebar-bar .sidebar-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
  user-select: none;
}

.sidebar-bar.sb-blue    { background: #3b82f6; }
.sidebar-bar.sb-green   { background: #16a34a; }
.sidebar-bar.sb-yellow  { background: #ca8a04; }
.sidebar-bar.sb-orange  { background: #ea580c; }
.sidebar-bar.sb-red     { background: #dc2626; }
.sidebar-bar.sb-darkred { background: #7c2d12; }
.sidebar-bar.sb-gray    { background: #9ca3af; }

.sidebar-bar.sb-active {
  width: 34px;
  border-right: 3px solid #1e293b;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .sidebar-rankings {
    display: none;
  }
  .nav-inner {
    height: 48px;
  }

  .nav-title {
    font-size: 1rem;
  }

  .nav-tab {
    padding: 5px 10px;
    font-size: 0.8125rem;
  }

  .status-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 18px;
  }

  .status-right {
    font-size: 0.875rem;
  }

  .vote-section {
    padding: 18px 16px;
  }

  .star-rating .star {
    font-size: 1.875rem;
  }

  .chart-section {
    padding: 16px 12px;
  }

  .chart-rating {
    height: 220px;
  }

  .chart-volume {
    height: 100px;
  }

  .chart-variance {
    height: 160px;
  }

  .period-selector {
    flex-wrap: wrap;
  }

  .bottom-row {
    flex-direction: column;
  }

  .bottom-col:first-child {
    max-width: none;
    width: auto;
  }

  .variance-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .variance-section.expanded .variance-body {
    padding: 0 16px 16px;
    max-height: 400px;
  }

  .variance-toggle {
    padding: 12px 16px;
  }

  .category-label {
    width: 72px;
    font-size: 0.75rem;
  }

  .ranking-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .ranking-card {
    padding: 14px;
  }

  .ranking-avg {
    font-size: 1.25rem;
  }

  .chart-combined {
    min-height: 200px;
  }

  .rant-section {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 10px 32px;
  }

  .star-rating {
    gap: 4px;
  }

  .star-rating .star {
    font-size: 1.625rem;
  }

  .pill {
    padding: 6px 12px;
    font-size: 0.8125rem;
  }

  .submit-btn {
    width: 100%;
  }

  .comment-input-wrap {
    max-width: 100%;
  }

  .period-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
  }
}
