/*
Theme Name: NDStudyRoom Library
Theme URI: https://ndstudyroom.jp/
Author: NDStudyRoom
Description: 初回有効化時に教材カードを自動作成するNDStudyRoom専用テーマ。固定ページから教材URL・教科・状態・順番を管理可能。
Version: 2.1.1
Requires at least: 6.4
Requires PHP: 8.0
Text Domain: ndstudyroom
*/

:root {
  --nd-bg: #f7f9fc;
  --nd-surface: #ffffff;
  --nd-text: #1f2937;
  --nd-muted: #64748b;
  --nd-line: #dbe3ef;
  --nd-brand: #2f6fda;
  --nd-focus: #111827;
  --nd-radius: 18px;
  --nd-shadow: 0 8px 24px rgba(32, 63, 105, .09);
  --nd-max: 1440px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--nd-text);
  background: var(--nd-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--nd-focus);
  outline-offset: 4px;
}

.nd-site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--nd-line);
  backdrop-filter: blur(10px);
}
.nd-header-inner {
  width: min(calc(100% - 32px), var(--nd-max));
  min-height: 86px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}
.nd-brand {
  display: inline-flex;
  flex-direction: column;
  text-decoration: none;
}
.nd-brand-main {
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -.035em;
}
.nd-brand-main strong { color: var(--nd-brand); }
.nd-brand-sub {
  color: var(--nd-muted);
  font-size: .88rem;
  font-weight: 600;
}

.nd-main {
  width: min(calc(100% - 32px), var(--nd-max));
  margin: 0 auto;
  padding: 34px 0 64px;
}
.nd-intro {
  padding: 4px 0 30px;
}
.nd-intro h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  letter-spacing: -.025em;
}
.nd-intro p {
  margin: 0;
  color: var(--nd-muted);
  font-size: 1rem;
}

.nd-subject {
  --subject-color: var(--nd-brand);
  margin: 0 0 28px;
  padding: 22px;
  background: var(--nd-surface);
  border: 1px solid var(--nd-line);
  border-radius: 24px;
  box-shadow: var(--nd-shadow);
}
.nd-subject-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.nd-subject-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: color-mix(in srgb, var(--subject-color) 13%, white);
  border: 2px solid color-mix(in srgb, var(--subject-color) 40%, white);
  color: var(--subject-color);
  font-size: 1.65rem;
  font-weight: 800;
}
.nd-subject-title {
  margin: 0;
  color: var(--subject-color);
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  line-height: 1.2;
}
.nd-subject-count {
  margin-left: auto;
  color: var(--nd-muted);
  font-size: .9rem;
}

.nd-rail-wrap { position: relative; }
.nd-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(190px, 230px);
  gap: 14px;
  overflow-x: auto;
  padding: 4px 4px 14px;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--subject-color) transparent;
}
.nd-rail::-webkit-scrollbar { height: 8px; }
.nd-rail::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--subject-color) 55%, white);
  border-radius: 999px;
}
.nd-card {
  min-height: 214px;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid var(--nd-line);
  border-top: 6px solid var(--subject-color);
  border-radius: var(--nd-radius);
  box-shadow: 0 4px 14px rgba(31, 41, 55, .07);
  overflow: hidden;
}
.nd-card-link {
  height: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}
.nd-card-link:hover,
.nd-card-link:focus-visible {
  background: color-mix(in srgb, var(--subject-color) 5%, white);
}
.nd-card-icon {
  min-height: 58px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--subject-color);
}
.nd-card-title {
  margin: 8px 0 4px;
  font-size: 1.12rem;
  line-height: 1.35;
  text-align: center;
}
.nd-card-grade {
  margin: 0;
  color: var(--nd-muted);
  font-size: .86rem;
  text-align: center;
}
.nd-card-action {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--nd-line);
  color: var(--subject-color);
  font-weight: 800;
  text-align: center;
}
.nd-card.is-preparing {
  border-style: dashed;
  border-top-style: solid;
  background: #f8fafc;
}
.nd-card.is-preparing .nd-card-link {
  cursor: default;
  pointer-events: none;
  opacity: .72;
}
.nd-status {
  display: inline-flex;
  align-self: center;
  margin-top: auto;
  padding: 6px 12px;
  border: 1px solid var(--nd-line);
  border-radius: 999px;
  background: #fff;
  font-size: .88rem;
  font-weight: 800;
}

.nd-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 30px;
  background: #fff;
  border: 1px solid var(--nd-line);
  border-radius: 22px;
  box-shadow: var(--nd-shadow);
}
.nd-page h1 { margin-top: 0; }
.nd-back {
  display: inline-flex;
  margin-bottom: 18px;
  font-weight: 800;
  text-decoration: none;
}
.nd-back::before { content: "←"; margin-right: .45em; }

.nd-empty {
  padding: 32px;
  color: var(--nd-muted);
  text-align: center;
  background: #fff;
  border: 1px solid var(--nd-line);
  border-radius: 18px;
}

.nd-site-footer {
  border-top: 1px solid var(--nd-line);
  background: #fff;
}
.nd-footer-inner {
  width: min(calc(100% - 32px), var(--nd-max));
  margin: 0 auto;
  padding: 24px 0;
  color: var(--nd-muted);
  font-size: .88rem;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

@media (max-width: 700px) {
  .nd-header-inner { min-height: 72px; }
  .nd-main { width: min(calc(100% - 20px), var(--nd-max)); padding-top: 22px; }
  .nd-subject { padding: 16px; border-radius: 20px; }
  .nd-subject-icon { width: 44px; height: 44px; font-size: 1.35rem; }
  .nd-subject-count { display: none; }
  .nd-rail { grid-auto-columns: minmax(170px, 72vw); }
  .nd-page { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* v1以前のテーマ・ブロック装飾をトップ画面へ持ち込まない */
body.home,
body.front-page {
  background: var(--nd-bg) !important;
}
body.home .wp-site-blocks,
body.home .site,
body.home #page,
body.home .site-content,
body.home .entry-content,
body.home .wp-block-group,
body.home .wp-block-cover,
body.home .wp-block-columns {
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  width: auto !important;
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
}
body.home main,
body.home .nd-main {
  display: block !important;
}
body.home .entry-header,
body.home .entry-title,
body.home .post-thumbnail,
body.home .wp-block-post-title,
body.home .wp-block-post-content {
  display: none !important;
}


/* v2 管理しやすいホーム画面 */
.nd-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
.nd-intro-copy { min-width: 0; }
.nd-intro-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--nd-line);
  border-radius: 999px;
  background: #fff;
  color: var(--nd-muted);
  font-size: .88rem;
  font-weight: 800;
}
.nd-subject-description {
  margin: 4px 0 0;
  color: var(--nd-muted);
  font-size: .92rem;
}
.nd-subject-copy { min-width: 0; }
.nd-subject-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nd-scroll-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--nd-line);
  border-radius: 50%;
  background: #fff;
  color: var(--subject-color);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
}
.nd-scroll-button:hover { background: #f8fafc; }
.nd-scroll-button[disabled] { opacity: .35; cursor: default; }

.nd-card-thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 12px;
  background: #f1f5f9;
}
.nd-card-thumbnail img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.nd-card.no-thumbnail .nd-card-icon { min-height: 78px; }

@media (max-width: 700px) {
  .nd-intro { display: block; }
  .nd-intro-badge { margin-top: 14px; }
  .nd-scroll-button { display: none; }
}

.nd-card-grade{display:none!important;}
