@layer base, layout, components, utilities, pages;

/* =========================================
   Page: Barrel Types (バレル研磨の種類)
   Aesthetic: PRECISION MONOGRAPH

   Premium Japanese industrial catalog feel.
   Color-coded type cards with per-type accent,
   wide confident layouts, dramatic dark plates,
   generous whitespace, gold accent threading.

   Tokens: --td-*
   Fonts: --font-serif (Shippori Mincho), --font-display (DM Sans), --font-sans (Noto Sans JP)
   Animations: scroll-triggered via .is-visible
   ========================================= */

@layer pages {

  /* ── Design Tokens ── */
  .page-barrel-types {
    --td-bg: #ffffff;
    --td-surface: #f9f7f2;
    --td-surface-warm: #f3f0e8;
    --td-surface-cool: #edeae2;
    --td-dark: #111110;
    --td-dark-mid: #1e1d1b;
    --td-gold: #b38f2d;
    --td-gold-bright: #cba43a;
    --td-gold-pale: rgba(179, 143, 45, 0.06);
    --td-gold-glow: rgba(179, 143, 45, 0.12);
    --td-ink: #1a1714;
    --td-ink-mid: rgba(26, 23, 20, 0.68);
    --td-ink-muted: rgba(26, 23, 20, 0.42);
    --td-rule: rgba(26, 23, 20, 0.08);
    --td-rule-strong: rgba(26, 23, 20, 0.16);
    --td-ease: cubic-bezier(0.22, 0.61, 0.36, 1);

    color: var(--td-ink);
    background: var(--td-bg);
    font-family: var(--font-sans);
  }

  /* ── Body Container ── */
  .bt-body {
    padding: clamp(64px, 11vw, 120px) 0 clamp(80px, 13vw, 140px);
  }

  .bt-body__inner {
    display: grid;
    gap: clamp(100px, 16vw, 180px);
    max-width: 1320px;
  }

  /* =========================================
     Section Base
     ========================================= */
  .bt-section {
    display: grid;
    gap: clamp(40px, 6vw, 60px);
  }

  /* Dark plate inversion */
  .bt-section--cream {
    background: var(--td-dark);
    color: #e8e3d8;
    margin-inline: calc(-1 * var(--gutter));
    padding: clamp(72px, 12vw, 112px) var(--gutter);
    position: relative;
  }

  .bt-section--cream::before {
    content: "";
    position: absolute;
    top: 0;
    left: var(--gutter);
    right: var(--gutter);
    height: 1px;
    background: linear-gradient(90deg, var(--td-gold) 0%, var(--td-gold) 120px, transparent 120px);
  }

  .bt-section--cream .bt-section__eyebrow { color: var(--td-gold); }
  .bt-section--cream .bt-section__title { color: #fff; }
  .bt-section--cream .bt-section__lead { color: rgba(232, 227, 216, 0.6); }

  /* Section Head */
  .bt-section__head {
    display: grid;
    gap: clamp(10px, 1.8vw, 16px);
  }

  .bt-section__eyebrow {
    font-family: var(--font-display);
    font-size: clamp(0.68rem, 0.85vw, 0.76rem);
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--td-gold);
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .bt-section__eyebrow::before {
    content: "";
    width: 32px;
    height: 1px;
    background: currentColor;
    flex-shrink: 0;
  }

  .bt-section__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 3.2vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.35;
    color: var(--td-ink);
  }

  .bt-section__lead {
    margin: 0;
    font-size: clamp(0.92rem, 1.15vw, 1rem);
    line-height: 2;
    color: var(--td-ink-mid);
  }

  .bt-section__link {
    margin: 0;
    padding-top: clamp(8px, 1.5vw, 16px);
  }

  .bt-section__link a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: clamp(0.84rem, 1vw, 0.92rem);
    font-weight: 700;
    color: var(--td-gold);
    text-decoration: none;
    letter-spacing: 0.04em;
    padding: 10px 0;
    border-bottom: 2px solid var(--td-gold-pale);
    transition: border-color 0.4s var(--td-ease), gap 0.4s var(--td-ease);
  }

  .bt-section__link a::after {
    content: "\2192";
    transition: transform 0.4s var(--td-ease);
  }

  .bt-section__link a:hover {
    border-bottom-color: var(--td-gold);
    gap: 16px;
  }

  .bt-section__link a:hover::after {
    transform: translateX(4px);
  }

  /* Dark section link override */
  .bt-section--cream .bt-section__link a {
    color: var(--td-gold);
    border-bottom-color: rgba(179, 143, 45, 0.15);
  }

  .bt-section--cream .bt-section__link a:hover {
    border-bottom-color: var(--td-gold);
  }

  /* =========================================
     Overview Table
     ========================================= */
  .bt-overview__table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bt-overview__table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.88rem, 1.04vw, 0.96rem);
  }

  .bt-overview__table th,
  .bt-overview__table td {
    padding: clamp(16px, 2.2vw, 22px) clamp(20px, 2.8vw, 32px);
    text-align: left;
    border-bottom: 1px solid var(--td-rule);
  }

  .bt-overview__table thead th {
    background: var(--td-dark);
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.72rem, 0.88vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .bt-overview__table tbody tr:last-child td,
  .bt-overview__table tbody tr:last-child th {
    border-bottom: none;
  }

  .bt-overview__table tbody th {
    font-weight: 700;
    color: var(--td-ink);
    white-space: nowrap;
  }

  .bt-overview__table tbody td {
    color: var(--td-ink-mid);
    line-height: 1.7;
  }

  .bt-overview__table tbody tr {
    transition: background 0.2s var(--td-ease);
  }

  .bt-overview__table tbody tr:hover {
    background: var(--td-surface-warm);
  }

  .bt-overview__row--highlight {
    background: var(--td-gold-pale);
  }

  .bt-overview__row--highlight:hover {
    background: var(--td-gold-glow) !important;
  }

  .bt-overview__row--highlight strong {
    display: inline-block;
    padding: 3px 12px;
    background: var(--td-gold);
    color: #fff;
    font-size: 0.82em;
    font-weight: 700;
  }

  /* =========================================
     Barrel Type Card — Color-coded accent top
     ========================================= */
  .bt-type {
    display: grid;
    gap: clamp(28px, 4.5vw, 44px);
    background: var(--td-surface);
    border: 1px solid var(--td-rule);
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.4s var(--td-ease);
  }

  .bt-type::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bt-accent, var(--td-ink-muted));
  }

  .bt-type:hover {
    box-shadow: 0 12px 48px rgba(26, 23, 20, 0.08);
  }

  .bt-type > * {
    padding-inline: clamp(28px, 4.5vw, 48px);
  }

  .bt-type > *:first-child {
    padding-top: clamp(32px, 5vw, 52px);
  }

  .bt-type > *:last-child {
    padding-bottom: clamp(32px, 5vw, 52px);
  }

  /* Highlight card (individual barrel) */
  .bt-type--highlight {
    border: 2px solid var(--bt-accent, var(--td-gold));
  }

  .bt-type--highlight::before {
    height: 5px;
  }

  /* Header */
  .bt-type__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(12px, 2vw, 18px);
  }

  .bt-type__badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    font-family: var(--font-display);
    font-size: clamp(0.7rem, 0.85vw, 0.78rem);
    font-weight: 700;
    color: #fff;
    background: var(--bt-accent, var(--td-ink-muted));
    letter-spacing: 0.06em;
  }

  .bt-type__title-group {
    display: grid;
    gap: 3px;
  }

  .bt-type__en {
    font-family: var(--font-display);
    font-size: clamp(0.64rem, 0.8vw, 0.72rem);
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--bt-accent, var(--td-ink-muted));
  }

  .bt-type__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(1.4rem, 2.4vw, 1.85rem);
    font-weight: 700;
    color: var(--td-ink);
    letter-spacing: 0.02em;
  }

  .bt-type__highlight-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 16px;
    font-family: var(--font-display);
    font-size: clamp(0.66rem, 0.8vw, 0.74rem);
    font-weight: 700;
    color: var(--bt-accent, var(--td-gold));
    background: rgba(179, 143, 45, 0.06);
    border: 1.5px solid var(--bt-accent, var(--td-gold));
    margin-left: auto;
  }

  .bt-type__highlight-label::before {
    content: "\2605";
    font-size: 0.85em;
  }

  /* Body */
  .bt-type__body {
    display: grid;
    gap: clamp(28px, 4.5vw, 48px);
  }

  .bt-type__block {
    display: grid;
    gap: clamp(12px, 1.8vw, 18px);
  }

  .bt-type__block p {
    margin: 0;
    font-size: clamp(0.92rem, 1.1vw, 1rem);
    line-height: 1.95;
    color: var(--td-ink-mid);
    padding: clamp(20px, 3vw, 32px);
    background: var(--td-surface-warm);
    border-left: 2px solid var(--bt-accent, var(--td-rule));
  }

  .bt-type__heading {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(0.78rem, 0.95vw, 0.88rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--td-ink-muted);
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .bt-type__heading::before {
    content: "";
    width: 3px;
    height: 1em;
    background: var(--bt-accent, var(--td-ink-muted));
    flex-shrink: 0;
  }

  .bt-type__heading--pros {
    color: #3d7c47;
  }

  .bt-type__heading--pros::before {
    background: #3d7c47;
  }

  .bt-type__heading--cons {
    color: #8b5e5e;
  }

  .bt-type__heading--cons::before {
    background: #8b5e5e;
  }

  /* Specs Table */
  .bt-type__specs {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.88rem, 1.04vw, 0.96rem);
    border: 1px solid var(--td-rule);
  }

  .bt-type__specs th,
  .bt-type__specs td {
    padding: clamp(12px, 1.8vw, 18px) clamp(18px, 2.5vw, 26px);
    text-align: left;
    border-bottom: 1px solid var(--td-rule);
  }

  .bt-type__specs tr:last-child th,
  .bt-type__specs tr:last-child td {
    border-bottom: none;
  }

  .bt-type__specs th {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.8rem, 0.94vw, 0.88rem);
    color: var(--td-ink);
    white-space: nowrap;
    width: 150px;
    background: var(--td-surface-warm);
  }

  .bt-type__specs td {
    color: var(--td-ink-mid);
    line-height: 1.7;
  }

  /* Pros / Cons Grid */
  .bt-type__proscons {
    display: grid;
    gap: clamp(20px, 3vw, 32px);
  }

  @media (min-width: 640px) {
    .bt-type__proscons {
      grid-template-columns: 1fr 1fr;
    }
  }

  .bt-type__pros,
  .bt-type__cons {
    display: grid;
    gap: clamp(10px, 1.5vw, 14px);
    align-content: start;
  }

  .bt-type__pros ul,
  .bt-type__cons ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 2px;
  }

  .bt-type__pros li,
  .bt-type__cons li {
    font-size: clamp(0.88rem, 1.04vw, 0.94rem);
    line-height: 1.8;
    color: var(--td-ink-mid);
    padding: clamp(12px, 1.8vw, 16px) clamp(16px, 2.2vw, 22px);
    padding-left: clamp(34px, 3.5vw, 44px);
    position: relative;
    background: var(--td-surface-warm);
    transition: background 0.2s var(--td-ease);
  }

  .bt-type__pros li:hover,
  .bt-type__cons li:hover {
    background: var(--td-surface-cool);
  }

  .bt-type__pros li::before {
    content: "+";
    position: absolute;
    left: clamp(12px, 1.6vw, 18px);
    font-family: var(--font-display);
    font-weight: 800;
    color: #3d7c47;
  }

  .bt-type__cons li::before {
    content: "\2013";
    position: absolute;
    left: clamp(12px, 1.6vw, 18px);
    font-weight: 700;
    color: #8b5e5e;
  }

  /* Uses — Tag-style pills */
  .bt-type__uses {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .bt-type__uses li {
    font-size: clamp(0.82rem, 0.96vw, 0.9rem);
    line-height: 1;
    color: var(--td-ink);
    padding: 10px 18px;
    background: var(--td-surface-warm);
    border: 1px solid var(--td-rule);
    font-weight: 500;
    transition: background 0.2s var(--td-ease), border-color 0.2s var(--td-ease);
  }

  .bt-type:hover .bt-type__uses li {
    background: var(--td-surface-cool);
  }

  /* Extra (individual barrel callout) */
  .bt-type__extra {
    display: grid;
    gap: clamp(14px, 2.2vw, 20px);
    padding: clamp(28px, 4vw, 44px);
    background: var(--td-gold-pale);
    border-left: 3px solid var(--td-gold);
  }

  .bt-type__extra p {
    margin: 0;
    font-size: clamp(0.92rem, 1.1vw, 1rem);
    line-height: 1.85;
    color: var(--td-ink);
  }

  /* =========================================
     Matrix Table — Selection guide (dark section)
     ========================================= */
  .bt-matrix__table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bt-matrix__table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.88rem, 1.04vw, 0.96rem);
    text-align: center;
  }

  .bt-matrix__table th,
  .bt-matrix__table td {
    padding: clamp(16px, 2.2vw, 22px) clamp(20px, 2.8vw, 32px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .bt-matrix__table thead th {
    background: rgba(179, 143, 45, 0.1);
    color: var(--td-gold);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.74rem, 0.9vw, 0.82rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .bt-matrix__table tbody th {
    text-align: left;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.03);
  }

  .bt-matrix__table tbody tr:last-child td,
  .bt-matrix__table tbody tr:last-child th {
    border-bottom: none;
  }

  .bt-matrix__table tbody td {
    color: rgba(232, 227, 216, 0.7);
  }

  .bt-matrix__table tbody tr {
    transition: background 0.2s var(--td-ease);
  }

  .bt-matrix__table tbody tr:hover td,
  .bt-matrix__table tbody tr:hover th {
    background: rgba(255, 255, 255, 0.04);
  }

  .bt-matrix__rating {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-weight: 800;
    font-size: 0.95em;
  }

  td[data-rating="◎"] .bt-matrix__rating {
    background: rgba(179, 143, 45, 0.2);
    color: var(--td-gold);
  }

  td[data-rating="○"] .bt-matrix__rating {
    background: rgba(232, 227, 216, 0.1);
    color: rgba(232, 227, 216, 0.8);
  }

  td[data-rating="△"] .bt-matrix__rating {
    background: rgba(232, 227, 216, 0.05);
    color: rgba(232, 227, 216, 0.4);
  }

  .bt-matrix__legend {
    display: flex;
    gap: clamp(20px, 3.5vw, 32px);
    flex-wrap: wrap;
    padding: clamp(16px, 2.5vw, 22px) 0;
  }

  .bt-matrix__legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.82rem, 0.96vw, 0.9rem);
    color: rgba(232, 227, 216, 0.6);
  }

  .bt-matrix__legend-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-weight: 800;
    font-size: 0.85em;
  }

  .bt-matrix__legend-item[data-rating="◎"] .bt-matrix__legend-symbol {
    background: rgba(179, 143, 45, 0.2);
    color: var(--td-gold);
  }

  .bt-matrix__legend-item[data-rating="○"] .bt-matrix__legend-symbol {
    background: rgba(232, 227, 216, 0.1);
    color: rgba(232, 227, 216, 0.8);
  }

  .bt-matrix__legend-item[data-rating="△"] .bt-matrix__legend-symbol {
    background: rgba(232, 227, 216, 0.05);
    color: rgba(232, 227, 216, 0.4);
  }

  /* =========================================
     Flowchart — Decision steps (dark section)
     ========================================= */
  .bt-flowchart {
    display: grid;
    gap: clamp(20px, 3vw, 32px);
  }

  .bt-flowchart__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 1.5vw, 1.3rem);
    font-weight: 700;
    color: #fff;
  }

  .bt-flowchart__steps {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .bt-flowchart__step {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: clamp(14px, 2.2vw, 22px);
    align-items: center;
    padding: clamp(20px, 3.2vw, 30px) clamp(22px, 3.2vw, 34px);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.25s var(--td-ease);
  }

  .bt-flowchart__step:first-child {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .bt-flowchart__step:hover {
    background: rgba(255, 255, 255, 0.06);
  }

  .bt-flowchart__index {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--td-gold);
    color: var(--td-dark);
    font-family: var(--font-display);
    font-size: clamp(0.84rem, 0.98vw, 0.92rem);
    font-weight: 800;
    flex-shrink: 0;
  }

  .bt-flowchart__question {
    font-size: clamp(0.94rem, 1.12vw, 1.02rem);
    font-weight: 700;
    color: #fff;
  }

  .bt-flowchart__answers {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .bt-flowchart__answer {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: clamp(0.82rem, 0.96vw, 0.9rem);
  }

  .bt-flowchart__answer-label {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(0.64rem, 0.74vw, 0.7rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 10px;
  }

  .bt-flowchart__answer--yes .bt-flowchart__answer-label {
    background: var(--td-gold);
    color: var(--td-dark);
  }

  .bt-flowchart__answer--no .bt-flowchart__answer-label {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(232, 227, 216, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .bt-flowchart__answer-value {
    color: rgba(232, 227, 216, 0.6);
    font-weight: 600;
  }

  .bt-flowchart__answer--yes .bt-flowchart__answer-value {
    color: var(--td-gold);
    font-weight: 700;
  }

  @media (max-width: 639px) {
    .bt-flowchart__step {
      grid-template-columns: 40px 1fr;
    }

    .bt-flowchart__answers {
      grid-column: 1 / -1;
      padding-left: 52px;
    }
  }

  /* =========================================
     Equipment Table
     ========================================= */
  .bt-equipment__table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.88rem, 1.04vw, 0.96rem);
  }

  .bt-equipment__table th,
  .bt-equipment__table td {
    padding: clamp(16px, 2.2vw, 22px) clamp(20px, 2.8vw, 32px);
    text-align: left;
    border-bottom: 1px solid var(--td-rule);
  }

  .bt-equipment__table thead th {
    background: var(--td-dark);
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.72rem, 0.88vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .bt-equipment__table tbody td {
    color: var(--td-ink-mid);
    line-height: 1.7;
  }

  .bt-equipment__table tbody tr:last-child td {
    border-bottom: none;
  }

  .bt-equipment__table tbody tr {
    transition: background 0.2s var(--td-ease);
  }

  .bt-equipment__table tbody tr:hover {
    background: var(--td-surface-warm);
  }

  /* =========================================
     Animations — Scroll-triggered
     ========================================= */
  @media (prefers-reduced-motion: no-preference) {
    .bt-type,
    .bt-flowchart__step {
      opacity: 0;
      transform: translateY(24px);
      transition: opacity 0.6s var(--td-ease), transform 0.6s var(--td-ease);
    }

    .bt-type.is-visible,
    .bt-flowchart__step.is-visible {
      opacity: 1;
      transform: translateY(0);
    }

    .bt-type:nth-of-type(2) { transition-delay: 0.05s; }
    .bt-type:nth-of-type(3) { transition-delay: 0.10s; }
    .bt-type:nth-of-type(4) { transition-delay: 0.15s; }
    .bt-type:nth-of-type(5) { transition-delay: 0.20s; }

    .bt-flowchart__step:nth-child(2) { transition-delay: 0.06s; }
    .bt-flowchart__step:nth-child(3) { transition-delay: 0.12s; }
    .bt-flowchart__step:nth-child(4) { transition-delay: 0.18s; }
  }

  @media (prefers-reduced-motion: reduce) {
    .bt-type,
    .bt-flowchart__step {
      opacity: 1;
      transform: none;
    }
  }

}
