/* ===== f5a-gallery — Light Theme Design System ===== */

:root {
  /* Page & Surface */
  --bg: #F9F8F6;
  --bg-white: #FFFFFF;
  --bg-footer: #E8F0E9;

  /* Text */
  --text-primary: #3C5440;
  --text-secondary: #4D6954;
  --text-body: #55524E;
  --text-sub: #8A8782;

  /* Green Palette */
  --green-dark: #3C5440;
  --green-mid: #5A7E63;
  --green-accent: #688F73;
  --green-light: #D6E8DA;
  --green-pale: #E8F0E9;

  /* Border & Shadow */
  --border: #E8E6E3;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);

  /* Keyboard Legend */
  --legend-popup: #F2994A;
  --legend-clipboard: #B7D5C2;
  --legend-active: #6DA8D6;
  --legend-comment: #A87BD6;

  /* Spacing */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --gap: 24px;
  --section-gap: 40px;

  /* Z-index */
  --z-menu: 1000;
  --z-popup: 2000;

  /* Typography scale */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  /* Radius */
  --radius-xs: 3px;
  --radius-pill: 20px;

  /* Font */
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', 'Fira Code', monospace;
}

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

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--green-mid);
  text-decoration: none;
  transition: opacity 0.15s;
}
a:hover { opacity: 0.8; }

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

/* ===== Container ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ===== Navigation ===== */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin: 0 0 16px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 14px;
  color: var(--text-body);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--green-mid);
  opacity: 1;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1.5px solid var(--green-accent);
  background: var(--bg-white);
  color: var(--green-dark);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--green-pale);
  opacity: 1;
}

.btn:active { transform: scale(0.97); }

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

.btn-primary:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.btn-github {
  background: #24292e;
  border-color: #24292e;
  color: #fff;
}

.btn-github:hover {
  background: #444d56;
  border-color: #444d56;
}

#github-login-area {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#github-user-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* ===== Theme Card Grid ===== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 8px;
}

.theme-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.theme-card:hover {
  border-color: var(--green-accent);
  box-shadow: var(--shadow-md);
}

.theme-card.active {
  border-color: var(--green-accent);
  box-shadow: 0 0 0 2px rgba(104, 143, 115, 0.2);
}

.theme-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-card-meta {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 12px;
}

.theme-card-palette {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.theme-card-swatch {
  flex: 1;
  height: 28px;
  border-radius: 4px;
  outline: 1px solid var(--border);
}

.theme-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.theme-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-card-likes {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sub);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.theme-card-likes:hover {
  background: var(--bg);
  color: var(--accent);
}

.theme-card-likes:hover svg {
  stroke: var(--accent);
  fill: var(--accent);
}

.theme-card-likes.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.theme-card-likes.disabled:hover {
  background: none;
  color: var(--text-sub);
}

.theme-card-likes.disabled:hover svg {
  stroke: var(--text-sub);
  fill: none;
}

.theme-card-likes svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
}

.theme-card-likes.liked svg {
  fill: #e74c3c;
  stroke: #e74c3c;
}

/* Favorite button */
.theme-card-fav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sub);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.theme-card-fav:hover {
  background: var(--bg);
  color: #f39c12;
}

.theme-card-fav svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
}

.theme-card-fav.favorited svg {
  fill: #f39c12;
  stroke: #f39c12;
}

.theme-card-fav.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.theme-card-fav.disabled:hover {
  background: none;
  color: var(--text-sub);
}

.fav-count {
  font-size: 12px;
}

/* ===== Detail Page ===== */
.detail-page {
  padding: 20px 0 60px;
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-sub);
  font-size: 14px;
  margin-bottom: 24px;
}

.detail-back:hover { color: var(--text-body); opacity: 1; }

.detail-preview {
  max-width: 440px;
  margin: 0 auto 32px;
}

.detail-header {
  text-align: center;
  margin-bottom: 24px;
}

.detail-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.detail-meta {
  font-size: 14px;
  color: var(--text-sub);
}

.detail-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 32px;
}

/* Color details */
.color-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 12px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px;
}

.color-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--border);
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.color-label { color: var(--text-sub); font-size: 11px; }
.color-value { font-family: var(--font-mono); font-size: 11px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container { padding: 0 16px; }

  .site-nav {
    flex-wrap: nowrap;
    gap: 0;
    margin-bottom: 16px;
  }

  .nav-links { display: none; }

  .nav-right { gap: 8px; }

  .nav-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-body);
    cursor: pointer;
    border-radius: var(--radius-sm);
  }

  .nav-hamburger:hover {
    background: var(--green-pale);
  }

  .theme-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* Hamburger hidden on desktop */
.nav-hamburger { display: none; }
@media (max-width: 768px) {
  .nav-hamburger { display: flex; }
}

@media (max-width: 480px) {
  .theme-grid { gap: 10px; }
  .theme-card { padding: 12px; }
  .color-grid { grid-template-columns: 1fr; }
}

/* ===== Shared Popup ===== */
.theme-popup {
  display: none;
  position: fixed;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 380px;
  width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: var(--z-popup);
  border: 1px solid var(--border);
}

.theme-popup-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  font-size: 15px; color: var(--text-sub);
  cursor: pointer; border-radius: var(--radius-sm);
}

.theme-popup-close:hover { background: var(--green-pale); }

.theme-popup-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.theme-popup-kb { margin-bottom: 14px; }

.theme-popup-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ===== Shared Badge ===== */
.builtin-badge {
  display: inline-block;
  background: rgba(90, 126, 99, 0.1);
  color: var(--green-mid);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 3px;
  min-height: 28px;
}

/* ===== Shared Button Sizes ===== */
.btn-sm {
  padding: 10px 16px;
  font-size: 13px;
  min-height: 44px;
}

/* ===== Focus States ===== */
.btn:focus-visible,
.theme-card:focus-visible,
.filter-btn:focus-visible,
.color-dot:focus-visible,
.nav-hamburger:focus-visible {
  outline: 2px solid var(--green-accent);
  outline-offset: 2px;
}

/* ===== Site Footer ===== */
.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 32px 24px;
  background: var(--bg-footer);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Footer needs top spacing when it's the first element after container */
.container + .site-footer,
.container ~ .site-footer {
  margin-top: 0;
  padding-top: 40px;
}

.footer-grid {
  display: flex;
  gap: 48px;
  margin-bottom: 32px;
}

.footer-col h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.footer-col p {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.7;
  margin-bottom: 8px;
}

.footer-col a {
  font-size: 13px;
  color: var(--green-mid);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-col li {
  font-size: 13px;
  color: var(--text-body);
  padding: 3px 0;
}

.footer-col li a {
  color: var(--text-body);
}

.footer-col li a:hover {
  color: var(--green-mid);
}

.footer-bottom {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

@media (max-width: 768px) {
  .footer-grid {
    flex-direction: column;
    gap: 24px;
    margin-bottom: 32px;
  }
}

/* ===== Mobile Bottom-Sheet Popup ===== */
.theme-popup.mobile-sheet {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  max-width: 100% !important;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  transform: translateY(0);
  animation: slideUp 0.25s ease-out;
}

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

/* ===== Shared QR Modal ===== */
.qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.qr-modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  position: relative;
}
.qr-modal-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.qr-modal-content > p {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 20px;
}
.qr-code {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.qr-code svg { width: 100%; height: 100%; }
.qr-filename {
  font-size: 12px;
  color: var(--text-sub);
  font-family: var(--font-mono);
}
.qr-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--text-sub);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.qr-modal-close:hover { background: var(--bg); }

@media (max-width: 480px) {
  .qr-modal-content { padding: 24px 16px; }
}
