/* ==========================================================================
   ChalaDev Reusable Components
   ========================================================================== */

/* --- Sticky Header & Navigation --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(16, 17, 20, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: var(--nav-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 0;
  flex: 0 1 auto;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-role {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-panel {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--dur-fast) var(--ease-editorial), border-color var(--dur-fast) var(--ease-editorial);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

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

.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.lang-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-editorial), color var(--dur-fast) var(--ease-editorial);
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.nav-toggle {
  display: none;
  appearance: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  min-width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-toggle:hover {
  border-color: var(--border-strong);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-editorial),
    border-color var(--dur-fast) var(--ease-editorial),
    color var(--dur-fast) var(--ease-editorial),
    transform var(--dur-fast) var(--ease-editorial);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.84rem;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 0.96rem;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
  transform: translateY(-1px);
}

.btn-surface {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-surface:hover {
  background: var(--bg-elevated);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-muted {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  cursor: default;
}

/* --- Status & Technical Tags --- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
}

.status-in_store {
  background: var(--status-store-bg);
  border-color: var(--status-store-border);
  color: var(--status-store-text);
}

.status-in_review {
  background: var(--status-review-bg);
  border-color: var(--status-review-border);
  color: var(--status-review-text);
}

.status-github {
  background: var(--status-github-bg);
  border-color: var(--status-github-border);
  color: var(--status-github-text);
}

.tech-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--accent-text);
  background: rgba(234, 88, 12, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.32);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  white-space: nowrap;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
}

/* --- Expandable Card & Accordion Pattern --- */
.expand-heading {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.expand-trigger {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: block;
  transition: background-color var(--dur-fast) var(--ease-editorial);
}

.expand-trigger:hover {
  background: rgba(255, 255, 255, 0.025);
}

.expand-trigger--compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.expand-title-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.expand-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.expand-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition:
    transform var(--dur-base) var(--ease-editorial),
    color var(--dur-fast) var(--ease-editorial),
    border-color var(--dur-fast) var(--ease-editorial);
}

.expand-trigger:hover .expand-icon {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

[data-expandable-card][data-expanded="true"] .expand-icon {
  transform: rotate(180deg);
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.expand-panel {
  display: grid;
  grid-template-rows: 1fr;
  transition:
    grid-template-rows var(--dur-base) var(--ease-editorial),
    opacity var(--dur-fast) var(--ease-editorial),
    visibility var(--dur-base) var(--ease-editorial);
}

html.js [data-expandable-card][data-expanded="false"] > .expand-panel {
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
}

html.js [data-expandable-card][data-expanded="true"] > .expand-panel {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
}

.expand-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.expand-copy {
  margin: 0;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* --- Product Card --- */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-top: 2px solid var(--product-accent, var(--accent));
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--dur-base) var(--ease-editorial);
}

.product-card:hover,
.product-card[data-expanded="true"] {
  border-color: var(--border-strong);
  border-top-color: var(--product-accent, var(--accent));
}

.product-card-trigger {
  display: grid;
  gap: 10px;
  padding: 20px 22px;
  font-weight: 400;
}

.product-card[data-expanded="true"] .product-card-trigger {
  border-bottom: 1px solid var(--border-subtle);
}

.product-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.product-head-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.product-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.product-identity-text {
  display: block;
  min-width: 0;
}

.product-icon {
  width: 40px;
  height: 40px;
  padding: 5px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.product-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.product-name {
  display: block;
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.product-submeta {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.product-tagline {
  display: block;
  color: var(--text-secondary);
  font-size: 0.89rem;
  line-height: 1.48;
}

.product-card-media {
  display: block;
  position: relative;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.product-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-base) var(--ease-editorial);
}

.product-card:hover .product-card-media img {
  transform: scale(1.015);
}

.product-card-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 20px 22px 22px;
  gap: 14px;
}

.product-summary {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.55;
}

.product-highlights {
  list-style: none;
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.48;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.product-highlights li {
  position: relative;
  padding-left: 16px;
}

.product-highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--product-accent, var(--accent));
}

.product-stores {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-actions {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* --- Tables --- */
.table-frame {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.spec-table th,
.spec-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.spec-table th {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.spec-table tbody tr:last-child td {
  border-bottom: 0;
}

.spec-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.spec-table td:first-child {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* --- Notice Banner (e.g., PayPal status in pro.php) --- */
.notice-banner {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.94rem;
}

.notice-banner.is-ok {
  border-color: var(--status-store-border);
  background: var(--status-store-bg);
  color: var(--status-store-text);
}

.notice-banner.is-error {
  border-color: var(--status-error-border);
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

/* --- Lightbox Dialog --- */
.media-lightbox {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 0;
  max-width: min(1160px, 94vw);
  width: 100%;
  margin: auto;
}

.media-lightbox::backdrop {
  background: rgba(16, 17, 20, 0.88);
  backdrop-filter: blur(4px);
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-stage {
  background: var(--bg-canvas);
  padding: 12px;
}

.lightbox-stage img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  padding: 64px 0 40px;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: 36px;
}

.footer-brand-desc {
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 34ch;
}

.footer-heading {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.footer-list {
  list-style: none;
  display: grid;
  gap: 9px;
  font-size: 0.9rem;
}

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

.footer-list a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* --- Mobile Navigation Drawer --- */
@media (max-width: 960px) {
  .nav-toggle {
    display: inline-flex;
  }

  .nav-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-strong);
    padding: 20px 24px 24px;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .nav-panel.is-open {
    display: flex;
  }

  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .nav-links a {
    display: block;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .nav-actions {
    justify-content: space-between;
    padding-top: 6px;
  }
}

@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .navbar {
    gap: 12px;
  }

  .brand-role {
    font-size: 0.66rem;
  }

  .product-card-head {
    flex-wrap: wrap;
  }

  .product-head-right {
    margin-left: auto;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }
}
