/* 縁(リム)が光源パラメータで光るSVGボタンのデモ */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 120% at 50% 26%, #1b1e26 0%, #0a0b0f 72%);
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  color: #e8eaf0;
}

/* ヘッダー高さ。固定プレビューの top と共有して隙間なく密着させる */
:root {
  --header-h: 60px;
}

/* ヘッダー（ブランド＋他ツールへの導線） */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-h);
  padding: 0 28px;
  border-bottom: 1px solid #232833;
  background: rgba(10, 11, 15, 0.8);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}

header .brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
}

header .brand span {
  color: #22d3ee;
}

.lang-switch {
  font-size: 16px;
  border: 1px solid #232833;
  padding: 6px 14px;
  border-radius: 999px;
  color: #e8eaf0;
  text-decoration: none;
  transition:
    border-color 0.2s ease,
    color 0.2s ease;
}

.lang-switch:hover {
  border-color: #22d3ee;
  color: #22d3ee;
}

/* 中央のステージ（ボタン＋パネル） */
.stage {
  flex: 1;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 40px;
  /* 上パディングは0＝プレビューバーをヘッダーに密着させる。左右0は全幅バー用、下48は余白 */
  padding: 0 0 48px;
}

/* プレビュー：スクロール中もボタンが見えるよう上部に固定するバー */
.preview {
  position: sticky;
  top: var(--header-h); /* ヘッダーと同じ高さ＝隙間なく密着 */
  z-index: 10;
  justify-self: stretch;
  display: grid;
  justify-items: center;
  padding: 20px 16px;
  /* 後ろを流れるコントロールを隠すため、ヘッダーと同系の半透明＋ぼかし */
  background: rgba(10, 11, 15, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #232833;
}

/* AdSense */
.ad-wrap {
  max-width: 728px;
  width: 100%;
  margin: 32px auto;
  padding: 0 20px;
  text-align: center;
  min-height: 90px;
}

/* フッター */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 40px;
  color: #9aa3b4;
  font-size: 16px;
  border-top: 1px solid #232833;
  margin-top: 40px;
}

footer a {
  color: #e8eaf0;
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: #22d3ee;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  border: 1px solid #232833;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 16px;
  transition:
    border-color 0.2s ease,
    color 0.2s ease;
}

.footer-links a:hover {
  border-color: #22d3ee;
  color: #22d3ee;
}

@media (max-width: 520px) {
  /* ヘッダーを低くする分、共有変数も更新（preview の top も自動で追従し密着を維持） */
  :root {
    --header-h: 52px;
  }

  header {
    padding: 0 16px;
  }

  .preview {
    padding: 20px 16px;
  }

  footer {
    flex-direction: column;
    gap: 16px;
    padding: 24px 16px;
    text-align: center;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ボタン本体（SVGを背面、ラベルを前面に重ねる） */
.rim-btn {
  position: relative;
  width: 320px;
  height: 120px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.rim-btn:active {
  transform: translateY(2px) scale(0.99);
}

/* SVGはボタンと同じ実寸で描画（サイズはscript.jsが管理） */
/* セレクタを .rim-btn 子孫にしてUAの svg:not(:root){overflow:hidden} に勝たせる */
.rim-btn .rim-btn__svg {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  overflow: visible; /* ネオンのブルームがボタン外までにじめるように */
}

/* ラベルはSVGの上に重ねて常にくっきり */
.rim-btn__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: #cfd4de;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* 光パターン選択セクション（ボタン）。設定パネルの上に独立配置 */
.patterns {
  width: min(840px, 92vw);
  padding: 20px 24px;
  border: 1px solid #232833;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.patterns__title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  color: #9aa3b4;
}

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

.pattern-btn {
  font-size: 16px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid #333a47;
  background: #161922;
  color: #cfd4de;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.pattern-btn:hover {
  border-color: #22d3ee;
  color: #22d3ee;
}

.pattern-btn.is-active {
  border-color: #22d3ee;
  background: #22d3ee;
  color: #0a0b0f;
  font-weight: 700;
}

/* コントロールパネル（3列） */
.panel {
  width: min(840px, 92vw);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 22px;
  padding: 24px;
  border: 1px solid #232833;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

/* タブレット＝2列、スマホ＝1列 */
@media (max-width: 760px) {
  .panel {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .panel {
    grid-template-columns: 1fr;
  }
}

.field {
  display: grid;
  align-content: start;
  gap: 8px;
}

/* 全幅フィールド（ボタンテキスト等） */
.field--wide {
  grid-column: 1 / -1;
}

.field__text {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #232833;
  border-radius: 8px;
  background: #11141b;
  color: #e8eaf0;
  font-size: 16px;
  cursor: text;
}

.field__text:focus {
  outline: none;
  border-color: #22d3ee;
}

/* パターン選択（field__text を流用しつつネイティブselectの体裁を整える） */
.field__select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #9aa3b4 50%),
    linear-gradient(135deg, #9aa3b4 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 16px,
    calc(100% - 12px) 16px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* 選択中パターンに無関係なフィールドは非表示 */
.field[hidden] {
  display: none;
}

.field__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 16px;
  color: #9aa3b4;
}

.field__value {
  color: #22d3ee;
  font-weight: 700;
}

/* スライダーはシアン */
.field__slider {
  width: 100%;
  height: 22px;
  accent-color: #22d3ee;
  cursor: pointer;
}

.field__color {
  width: 100%;
  height: 38px;
  padding: 0;
  border: 1px solid #232833;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

/* アクション行（自動回転・リセット）はパネル全幅 */
.panel__actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
}

.btn {
  font-size: 16px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid #333a47;
  background: #161922;
  color: #cfd4de;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.btn:hover {
  border-color: #22d3ee;
  color: #22d3ee;
}

.btn[aria-pressed="true"] {
  border-color: #22d3ee;
  color: #22d3ee;
}

/* 生成コード出力（HTML/CSSの2カラム） */
.output {
  width: min(840px, 92vw);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 22px;
}

@media (max-width: 760px) {
  .output {
    grid-template-columns: 1fr;
  }
}

.output__col {
  display: grid;
  gap: 8px;
}

.output__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.output__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #9aa3b4;
}

.output__code {
  width: 100%;
  height: 220px;
  padding: 12px;
  border: 1px solid #232833;
  border-radius: 10px;
  background: #11141b;
  color: #cfd4de;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  white-space: pre;
  tab-size: 2;
}

.output__code:focus {
  outline: none;
  border-color: #22d3ee;
}

/* ── 記事（SEO/AIO可視コンテンツ）──────────────────── */
.article {
  width: min(840px, 92vw);
  margin: 56px auto 0;
  color: #cfd4de;
  font-size: 16px;
  line-height: 1.8;
}

.article h2 {
  margin: 40px 0 16px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #e8eaf0;
}

.article h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #e8eaf0;
}

.answer-box {
  padding: 18px 20px;
  border: 1px solid #1f3a44;
  border-left: 3px solid #22d3ee;
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.06);
}

.answer-box p {
  margin: 0;
}

.article .steps {
  margin: 0;
  padding-left: 1.4em;
}

.article .steps li {
  margin: 6px 0;
}

.article strong {
  color: #e8eaf0;
}

.pattern-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.pattern-table th,
.pattern-table td {
  padding: 10px 14px;
  border: 1px solid #232833;
  text-align: left;
}

.pattern-table th {
  background: rgba(255, 255, 255, 0.04);
  color: #9aa3b4;
  font-weight: 700;
}

.pattern-table td:first-child {
  white-space: nowrap;
  color: #e8eaf0;
  font-weight: 700;
}

.faq-item {
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid #232833;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.faq-item p {
  margin: 0;
}

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

.related a {
  padding: 9px 16px;
  border: 1px solid #333a47;
  border-radius: 999px;
  color: #cfd4de;
  text-decoration: none;
  font-size: 16px;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.related a:hover {
  border-color: #22d3ee;
  color: #22d3ee;
}
