/*
 * UI Components — まなび Learning Platform
 * Figmaコンポーネントと1:1対応
 */

/* === Buttons === */

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  padding: 11px 28px;
  border-radius: var(--zone-radius-button, var(--radius-pill));
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  display: inline-block;
  text-decoration: none;
  font-family: var(--font-family);
}
.btn-primary:hover {
  opacity: 0.9;
  color: #fff;
}

.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  padding: 10px 28px;
  border-radius: var(--zone-radius-button, var(--radius-pill));
  border: 1.5px solid var(--color-accent);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  text-decoration: none;
  font-family: var(--font-family);
}
.btn-secondary:hover {
  background: var(--color-accent);
  color: #fff;
}

.btn-corporate {
  background: var(--color-secondary);
  color: #fff;
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  padding: 10px 28px;
  border-radius: var(--zone-radius-button, var(--radius-pill));
  border: none;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  font-family: var(--font-family);
}

/* === Badges === */

.badge {
  display: inline-block;
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-xl);
  line-height: 1;
}
.badge--free {
  background: var(--color-accent);
  color: #fff;
  padding: 3px 10px;
  font-size: var(--text-badge);
}
.badge--paid {
  background: var(--color-secondary);
  color: #fff;
  padding: 3px 10px;
  font-size: var(--text-badge);
}
.badge--category {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  padding: 2px 8px;
  font-size: var(--text-tiny);
  border-radius: var(--radius-sm);
}
.badge--difficulty-mid {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  padding: 2px 8px;
  font-size: var(--text-tiny);
  border-radius: var(--radius-sm);
}
.badge--difficulty-easy {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  padding: 2px 8px;
  font-size: var(--text-tiny);
  border-radius: var(--radius-sm);
}
.badge--recommend {
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-small);
  padding: 6px;
  text-align: center;
  border-radius: 0;
}

/* === Cards === */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--zone-radius-card, var(--radius-lg));
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-card, var(--shadow-md));
}

.card__thumbnail {
  background: linear-gradient(135deg, #0D1B2A, #1a3a5c);
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.card__thumbnail-icon {
  font-size: 40px;
}
.card__thumbnail-badge {
  position: absolute;
  top: 10px;
  left: 10px;
}
.card__thumbnail-meta {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-tiny);
}
.card__thumbnail-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-badge);
}

.card__body {
  padding: var(--space-4);
}
.card__tags {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}
.card__title {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  font-size: var(--text-body);
  line-height: 1.4;
}
.card__description {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  margin-top: 6px;
  line-height: 1.6;
}
.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid #f0f0f0;
}
.card__meta {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
}

/* === Plan Card === */

.plan-card {
  background: var(--color-surface);
  border-radius: var(--zone-radius-card, var(--radius-xl));
  overflow: hidden;
}
.plan-card--default {
  border: 1px solid var(--color-border);
}
.plan-card--recommended {
  border: 2px solid var(--color-accent);
  box-shadow: var(--shadow-plan);
}
.plan-card--corporate {
  border: 1px solid var(--color-border);
}
.plan-card__header {
  padding: var(--space-7) var(--space-6);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}
.plan-card__label {
  font-size: 14px;
  font-weight: var(--weight-semibold);
}
.plan-card__label--free { color: var(--color-accent); }
.plan-card__label--standard { color: var(--color-accent); }
.plan-card__label--corporate { color: var(--color-secondary); }

.plan-card__price {
  font-size: 40px;
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-top: var(--space-2);
}
.plan-card__price-unit {
  font-size: 16px;
  font-weight: var(--weight-regular);
  color: var(--color-text-secondary);
}
.plan-card__note {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}
.plan-card__features {
  padding: var(--space-6);
}
.plan-card__feature {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-caption);
  color: var(--color-text-primary);
  line-height: 2.2;
}
.plan-card__feature--check { color: var(--color-accent); }
.plan-card__feature--disabled { opacity: 0.3; }

/* === Filter Tabs === */

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-tab {
  font-size: var(--text-small);
  padding: 6px 14px;
  border-radius: var(--zone-radius-button, var(--radius-pill));
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-family);
}
.filter-tab--active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

/* === Category Nav === */

.category-nav {
  display: flex;
  gap: var(--space-4);
  padding: 10px var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}
.category-nav__item {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  white-space: nowrap;
  padding-bottom: 6px;
  text-decoration: none;
}
.category-nav__item--active {
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
  border-bottom: 2px solid var(--color-accent);
}

/* === Progress Bar === */

.progress-bar {
  height: 6px;
  background: var(--color-accent-bg);
  border-radius: var(--radius-sm);
}
.progress-bar__fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  transition: width 0.3s;
}
.progress-bar--warning .progress-bar__fill {
  background: var(--color-warning);
}

/* === Diagnosis Result Bar === */

.result-bar {
  margin-bottom: var(--space-3);
}
.result-bar__header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-caption);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}
.result-bar__score {
  font-weight: var(--weight-semibold);
}
.result-bar__score--weak {
  color: var(--color-warning);
}

/* === FAQ Accordion === */

.faq-item {
  background: var(--color-surface);
  border-radius: var(--zone-radius-card, var(--radius-md));
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}
.faq-item__question {
  padding: var(--space-4) var(--space-5);
  font-size: 14px;
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item__answer {
  padding: 0 var(--space-5) var(--space-4);
  font-size: var(--text-caption);
  color: var(--color-text-body);
  line-height: 1.7;
  display: none;
}
.faq-item--open .faq-item__answer {
  display: block;
}

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

/* Section vertical rhythm: clamp gives 56px on small viewports, scales to
 * 96px on wide screens. Previously a flat 28px which made adjacent sections
 * (especially the dark Diagnosis → dark Cert pair) feel cramped. */
.section {
  padding: clamp(56px, 6vw, 96px) var(--space-6);
}
/* Extra breathing room when two adjacent sections share a dark background
 * — the eye needs more separation than usual. */
.section--dark + .section--surface,
.section--dark + .section[data-zone],
.section[data-zone] + .section[data-zone] {
  padding-top: clamp(72px, 7vw, 112px);
}
.section--bg {
  background: var(--color-bg);
}
.section--surface {
  background: var(--color-surface);
}
.section--dark {
  background: var(--color-primary);
  color: #fff;
}
.section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}
.section__title {
  font-size: var(--text-h3);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}
.section--dark .section__title {
  color: #fff;
}
.section__link {
  font-size: var(--text-caption);
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

/* === Grid Layouts === */

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }

@media (max-width: 768px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }

  .section {
    padding: var(--space-5) var(--space-4);
  }
  .section__title {
    font-size: var(--text-h3);
  }

  .compare-table {
    overflow-x: auto;
  }
  .compare-row {
    min-width: 560px;
    font-size: var(--text-small);
  }

  .card__thumbnail {
    height: 120px;
  }

  .plan-card__header {
    padding: var(--space-5) var(--space-4);
  }
  .plan-card__price {
    font-size: 32px;
  }
  .plan-card__features {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .grid-4,
  .grid-3 { grid-template-columns: 1fr; }
  .section {
    padding: var(--space-4) var(--space-3);
  }
  .compare-row {
    min-width: 480px;
  }
}

/* === Comparison Table === */

.compare-table {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.compare-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
}
.compare-row--header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.compare-row:not(:last-child) {
  border-bottom: 1px solid #f0f0f0;
}
.compare-row:nth-child(even) {
  background: #FAFBFC;
}
.compare-cell {
  padding: 10px var(--space-4);
  font-size: var(--text-caption);
  color: var(--color-text-primary);
}
.compare-cell--header {
  font-weight: var(--weight-semibold);
  text-align: center;
}
.compare-cell--check {
  color: var(--color-accent);
  text-align: center;
}
.compare-cell--disabled {
  opacity: 0.3;
  text-align: center;
}

/* ==========================================================================
 * Context-aware color/font overrides for headings in custom zones.
 * The `.entry-content h1-h6 { color/size inherit }` neutralize was moved
 * to css/astra-reset.css in Phase 4d; these remain because they're about
 * our own components (section--dark, hero-banner, card), not Astra.
 * ========================================================================== */
.section--dark :where(h1, h2, h3, h4, h5, h6, p) {
  color: #fff;
}
.hero-banner__main :where(h1, h2, h3, h4, h5, h6) {
  color: #fff;
}
.card :where(h1, h2, h3, h4, h5, h6) {
  color: var(--color-text-primary);
}

/* ==========================================================================
 * Legacy .lp-footer override
 *
 * functions.php injects <footer class="lp-footer"> with .lp-footer__grid
 * and .lp-footer__bottom as direct children, but the legacy child theme
 * style.css puts `max-width` / padding on a non-existent `.lp-footer__inner`
 * wrapper. So the first column clips to the viewport edge. Also the brand
 * class name in PHP is `.lp-footer__brand-name`, which legacy CSS never
 * styled. Patch it all here.
 * ========================================================================== */
.lp-footer {
  background: var(--color-text-primary, #0D1B2A);
  color: rgba(255, 255, 255, 0.7);
  padding: 56px 24px 24px;
}
.lp-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  max-width: 1240px;
  margin: 0 auto 32px;
}
.lp-footer__brand-name {
  font-weight: var(--weight-bold);
  font-size: 20px;
  color: #fff;
  margin-bottom: 12px;
}
.lp-footer__heading {
  font-size: var(--text-tiny);
  font-weight: var(--weight-bold);
  letter-spacing: 1px;
  color: #fff;
  margin-bottom: 14px;
}
.lp-footer__link {
  display: block;
  font-size: var(--text-caption);
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  margin-bottom: 10px;
}
.lp-footer__link:hover {
  color: var(--color-accent);
}
.lp-footer__bottom {
  max-width: 1240px;
  margin: 0 auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: var(--text-tiny);
  color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
  .lp-footer {
    padding: 40px 20px 20px;
  }
  .lp-footer__grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }
}

/* ==========================================================================
 * Lesson card (Phase 6 — editorial / magazine aesthetic)
 *
 * Two variants share the same DOM structure:
 *   .lesson-card             — regular grid card (人気 / カテゴリ別)
 *   .lesson-card--feature    — true-hero card (larger, dramatic)
 *
 * Without thumbnails, the visual weight comes from a colored upper block
 * (var(--card-accent)) acting as a faux artwork area, with the title set
 * over it in white. The excerpt + CTA live in the white lower half.
 *
 * --card-accent is set per-card via inline style from PHP
 * (see lp_lesson_categories() in inc/lessons.php).
 * ========================================================================== */
.lesson-card {
  --lc-radius: 14px;
  --lc-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
  --lc-shadow-hover: 0 16px 40px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);

  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--lc-radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--color-text-primary);
  box-shadow: var(--lc-shadow);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  height: 100%;
  isolation: isolate;
}
.lesson-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--lc-shadow-hover);
  color: var(--color-text-primary);
}

/* Top colored block — fake thumbnail area (or real YouTube thumb).
 * aspect-ratio 16:9 matches the YouTube mqdefault/maxresdefault
 * dimensions so real thumbnails fill without letterbox, and
 * gradient-fallback covers stay visually uniform next to them. */
.lesson-card__cover {
  position: relative;
  padding: 18px 22px 22px;
  background: linear-gradient(135deg,
    var(--card-accent, #4338CA) 0%,
    color-mix(in srgb, var(--card-accent, #4338CA) 75%, #000 25%) 100%);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  color: #fff;
  aspect-ratio: 16 / 9;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
/* Decorative giant initial letter behind title (subtle texture) */
.lesson-card__cover::before {
  content: attr(data-initial);
  position: absolute;
  top: -28px;
  right: -16px;
  font-size: 180px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255, 255, 255, 0.08);
  pointer-events: none;
  z-index: 0;
}

/* When a real YouTube thumbnail is present the cover uses it as
 * background (set inline via `style="background-image:url(...)"`).
 * An ::after overlay darkens the bottom so the title/tag stay legible,
 * and the category color is preserved as a thin left accent stripe. */
.lesson-card__cover--with-thumb::before {
  display: none; /* initial letter watermark hidden when a real image is used */
}
.lesson-card__cover--with-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      rgba(15, 23, 42, 0.05) 0%,
      rgba(15, 23, 42, 0.55) 55%,
      rgba(15, 23, 42, 0.88) 100%);
  z-index: 0;
  pointer-events: none;
}
.lesson-card__cover--with-thumb > * {
  position: relative;
  z-index: 1;
}
.lesson-card__cover--with-thumb {
  /* extra left accent bar in the category color so the thumb card still
   * carries the category identity */
  box-shadow: inset 4px 0 0 var(--card-accent, #4338CA);
}

.lesson-card__category-tag {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  backdrop-filter: blur(4px);
}

.lesson-card__title {
  position: relative;
  z-index: 1;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: -0.01em;
  margin: 0;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.lesson-card__body {
  padding: 18px 22px 14px;
  flex: 1 1 auto;
}

.lesson-card__excerpt {
  font-size: 13px;
  color: var(--color-text-secondary, #64748b);
  line-height: 1.75;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lesson-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 22px 22px;
  padding-top: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--card-accent, var(--color-accent));
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  letter-spacing: 0.02em;
}
.lesson-card__cta::after {
  content: '→';
  margin-left: 2px;
  transition: transform 0.25s ease;
}
.lesson-card:hover .lesson-card__cta::after {
  transform: translateX(4px);
}

/* ============================================================
 * Featured variant (true-hero pickup) — larger, more dramatic
 * ============================================================ */
.lesson-card--feature {
  --lc-radius: 18px;
}
.lesson-card--feature .lesson-card__cover {
  padding: 28px 28px 32px;
  /* aspect-ratio 16:9 inherited from .lesson-card__cover; no min-height */
}
.lesson-card--feature .lesson-card__cover::before {
  font-size: 260px;
  top: -48px;
  right: -28px;
  color: rgba(255, 255, 255, 0.10);
}
.lesson-card--feature .lesson-card__category-tag {
  font-size: 11px;
  padding: 6px 13px;
  margin-bottom: 18px;
}
.lesson-card--feature .lesson-card__title {
  font-size: 22px;
  line-height: 1.45;
  letter-spacing: -0.015em;
}
.lesson-card--feature .lesson-card__body {
  padding: 22px 28px 16px;
}
.lesson-card--feature .lesson-card__excerpt {
  font-size: 14px;
  -webkit-line-clamp: 4;
}
.lesson-card--feature .lesson-card__cta {
  margin: 0 28px 26px;
  padding-top: 16px;
  font-size: 14px;
}

/* Mobile: tighten paddings */
@media (max-width: 768px) {
  .lesson-card__cover { padding: 14px 16px 16px; }
  .lesson-card__cover::before { font-size: 140px; top: -20px; right: -12px; }
  .lesson-card__title { font-size: 15px; }
  .lesson-card__body { padding: 14px 18px 12px; }
  .lesson-card__cta { margin: 0 18px 18px; padding-top: 12px; font-size: 12px; }

  .lesson-card--feature .lesson-card__cover { padding: 20px 20px 22px; }
  .lesson-card--feature .lesson-card__title { font-size: 18px; }
  .lesson-card--feature .lesson-card__body { padding: 18px 22px 12px; }
}

/* Phase 4d: Astra .ast-container flex-direction override moved to
 * css/astra-reset.css. */

/* ==========================================================================
 * Legacy .lp-header override
 *
 * functions.php injects <header class="lp-header"> with logo/nav/cta/toggle
 * as direct children. The legacy child theme style.css only defines
 * `display:flex` on a non-existent `.lp-header__inner` wrapper, so children
 * fall back to block stacking. Also `position:fixed` makes the header cover
 * the hero label. And `.lp-hide-mobile` / `.lp-hide-desktop` are referenced
 * from the PHP markup but never defined in CSS. Patch it all here.
 * ========================================================================== */
.lp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  position: sticky;
  top: 0;
  left: auto;
  width: 100%;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
}
.lp-header__logo {
  flex: 0 0 auto;
  font-weight: var(--weight-bold);
  font-size: 20px;
  color: var(--color-text-primary);
  text-decoration: none;
}
.lp-header__nav {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-5);
}
.lp-header__nav a {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.lp-header__nav a:hover {
  color: var(--color-primary);
}
.lp-header__cta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  border-radius: var(--zone-radius-button, 8px);
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  font-weight: var(--weight-bold);
  font-size: var(--text-caption);
}
.lp-header__cta:hover {
  background: var(--color-primary);
  color: #fff;
}
.lp-header__menu-toggle {
  flex: 0 0 auto;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--color-text-primary);
}

/* Responsive visibility helpers referenced by functions.php lp-header markup */
@media (min-width: 922px) {
  .lp-hide-desktop { display: none !important; }
}
@media (max-width: 921px) {
  .lp-hide-mobile { display: none !important; }
  .lp-header {
    padding: var(--space-2) var(--space-4);
  }
}
