/*
Theme Name: あゆみ式 Ver.4
Theme URI: https://ayumishiki.com/
Author: あゆみ塾
Description: 無料学習プリント「あゆみ式」。学年をえらんで、すぐプリントへ。サムネイルなしの行一覧、PDF／コンビニ印刷の案内つき。
Version: 4.0.0
Requires at least: 6.4
Requires PHP: 8.0
Text Domain: ayumi-shiki
*/

:root {
  --paper: #fffdf7; --surface: #ffffff; --ink: #2a2826; --muted: #635e57; --line: #e6dfd0;
  --blue: #1f5fbf; --blue-dark: #174a97; --blue-soft: #e9f1ff;
  --es: #fff0c2; --es-line: #e9c96a; --jh: #e2edff; --jh-line: #9dbcf0; --hs: #e2f3e4; --hs-line: #96cf9f;
  --radius: 14px; --content: 880px; --tap: 48px;
  --c-japanese: #c8443c; --c-mathematics: #1f5fbf; --c-english: #7a4cc2; --c-science: #1e8a5a; --c-social-studies: #b26a00; --c-life: #5c7d1a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif; font-size: 16px; line-height: 1.7; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.screen-reader-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 10000; top: 8px; left: 8px; padding: 10px 16px; border-radius: 8px; background: #fff; color: var(--blue-dark); font-weight: 700; box-shadow: 0 4px 18px rgba(0, 0, 0, .2); transform: translateY(calc(-100% - 24px)); }
.skip-link:focus { transform: translateY(0); }
.container { width: min(var(--content), 100% - 32px); margin-inline: auto; }

/* ヘッダー */
.site-header { position: relative; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50% 46% 50% 48%; background: var(--blue); color: #fff; font-size: 18px; font-weight: 800; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; }
.brand-text small { color: var(--muted); font-size: 11px; }
.main-nav ul { display: flex; align-items: center; gap: 4px; }
.main-nav a { display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: 10px; font-size: 14px; font-weight: 700; }
.main-nav a:hover { background: var(--blue-soft); }
.menu-toggle { display: none; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 0 14px; font-size: 13px; font-weight: 700; cursor: pointer; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 10px 20px; border: 2px solid var(--blue); border-radius: 999px; font-weight: 800; font-size: 16px; line-height: 1.3; text-align: center; cursor: pointer; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-secondary { background: var(--surface); color: var(--blue-dark); }
.btn-secondary:hover { background: var(--blue-soft); }
.notice { padding: 16px; border-radius: var(--radius); background: var(--blue-soft); }

/* トップ */
.home-hero { padding: 22px 0 40px; text-align: center; }
.home-hero h1 { font-size: clamp(23px, 6.2vw, 38px); line-height: 1.35; letter-spacing: .02em; }
.nowrap { display: inline-block; white-space: nowrap; }
.home-lead { margin-top: 6px; color: var(--muted); font-size: 15px; }

/* 学年えらび */
.grade-picker--home { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 8px; max-width: 640px; margin: 18px auto 0; text-align: left; }
.grade-picker--home .grade-group--elementary { grid-column: span 6; }
.grade-picker--home .grade-group--junior, .grade-picker--home .grade-group--high { grid-column: span 3; }
.grade-group-label { margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 700; }
.grade-group ul { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.grade-group--elementary ul { grid-template-columns: repeat(6, 1fr); }
.grade-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; border: 2px solid var(--es-line); border-radius: var(--radius); background: var(--es); font-weight: 800; line-height: 1.15; }
.grade-group--junior .grade-btn { border-color: var(--jh-line); background: var(--jh); }
.grade-group--high .grade-btn { border-color: var(--hs-line); background: var(--hs); }
.grade-short { font-size: 19px; }
.grade-soon { color: var(--muted); font-size: 10px; font-weight: 700; }
.grade-btn.is-soon { background: var(--surface); border-style: dashed; }
.grade-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(0, 0, 0, .08); }
.grade-btn.is-current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* 学年の帯（学年ページの上） */
.grade-picker--strip { display: flex; gap: 14px; margin: 12px -16px 0; padding: 2px 16px 8px; overflow-x: auto; scrollbar-width: thin; }
.grade-picker--strip .grade-group { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.grade-picker--strip .grade-group-label { margin: 0; font-size: 11px; white-space: nowrap; }
.grade-picker--strip .grade-group ul { display: flex; gap: 6px; }
.grade-picker--strip .grade-btn { min-width: 48px; min-height: 44px; border-radius: 12px; }
.grade-picker--strip .grade-short { font-size: 15px; }
.grade-picker--strip .grade-soon { display: none; }

/* 特徴 */
.home-points { padding: 22px 0 36px; }
.home-points ul { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.home-points li { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); line-height: 1.4; }
.home-points li:last-child { grid-column: span 2; }
.home-points strong { font-size: 14px; }
.home-points span { color: var(--muted); font-size: 12px; }

/* 一覧ページ */
.list-main, .prose-main, .worksheet-detail { padding-bottom: 56px; }
.list-header { padding: 14px 0 10px; }
.list-header h1 { font-size: clamp(24px, 6vw, 32px); line-height: 1.3; }
.list-header h1 span { margin-left: 4px; color: var(--muted); font-size: 14px; font-weight: 700; }
.list-header p { color: var(--muted); font-size: 14px; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding-top: 12px; color: var(--muted); font-size: 13px; }
.breadcrumbs a { display: inline-flex; align-items: center; min-height: 40px; color: var(--blue-dark); text-decoration: underline; text-underline-offset: 3px; }

/* 教科タブ */
.subject-tabs { position: sticky; top: 0; z-index: 10; display: flex; gap: 6px; margin: 0 -16px; padding: 8px 16px; overflow-x: auto; background: var(--paper); scrollbar-width: none; }
.subject-tabs::-webkit-scrollbar { display: none; }
.subject-tab { display: inline-flex; flex: 1 0 auto; flex-direction: column; align-items: center; justify-content: center; min-width: 62px; min-height: var(--tap); padding: 4px 12px; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; background: var(--surface); font-weight: 800; line-height: 1.2; white-space: nowrap; }
.subject-tab small { color: var(--muted); font-size: 10px; font-weight: 700; }
.subject-tab.is-soon { border-style: dashed; border-bottom-width: 2px; background: transparent; color: var(--muted); font-weight: 700; }
a.subject-tab { border-bottom-color: var(--subject, var(--blue)); }
a.subject-tab[aria-current="true"] { border-color: var(--subject, var(--blue)); background: var(--subject, var(--blue)); color: #fff; }
.subject--japanese { --subject: var(--c-japanese); } .subject--mathematics { --subject: var(--c-mathematics); } .subject--english { --subject: var(--c-english); }
.subject--science { --subject: var(--c-science); } .subject--social-studies { --subject: var(--c-social-studies); } .subject--life { --subject: var(--c-life); }
.jump-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 8px; }
.jump-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 700; }

/* 単元名でさがす */
.ws-filter { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; }
.ws-filter label { flex: 0 0 auto; color: var(--muted); font-size: 13px; font-weight: 700; }
.ws-filter input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); }
.ws-empty { padding: 16px 0; color: var(--muted); }

/* 教材の行 */
.subject-panel { scroll-margin-top: 72px; }
.subject-panel h2 { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; padding-left: 10px; border-left: 6px solid var(--subject, var(--blue)); font-size: 18px; line-height: 1.3; }
.subject-panel h2 small { color: var(--muted); font-size: 12px; font-weight: 700; }
.ws-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.ws-row { display: flex; align-items: stretch; }
.ws-row + .ws-row { border-top: 1px solid var(--line); }
.ws-main { display: grid; flex: 1; min-width: 0; grid-template-columns: auto 1fr; grid-template-areas: "range meta" "names names"; align-items: baseline; gap: 0 10px; min-height: 56px; padding: 8px 8px 8px 14px; }
.ws-main:hover { background: var(--blue-soft); }
.ws-range { grid-area: range; font-size: 16px; font-weight: 800; white-space: nowrap; }
.ws-context { margin-right: 2px; color: var(--muted); font-size: 12px; font-weight: 700; }
.ws-meta { grid-area: meta; justify-self: end; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ws-names { grid-area: names; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.ws-pdf { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; flex-direction: column; min-width: 60px; margin: 6px 8px 6px 0; padding: 0 8px; border: 2px solid var(--blue); border-radius: 12px; color: var(--blue-dark); font-size: 14px; font-weight: 800; line-height: 1.15; }
.ws-pdf span { font-size: 10px; }
.ws-pdf:hover { background: var(--blue); color: #fff; }

/* 準備中 */
.soon-panel { margin-top: 12px; padding: 22px 18px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.soon-panel h1, .soon-panel h2 { font-size: 19px; line-height: 1.5; }
.soon-panel p { margin-top: 8px; color: var(--muted); font-size: 14px; }

/* 検索フォーム */
.filter-form { display: grid; gap: 8px; margin: 6px 0 14px; }
.filter-form input[type="search"], .filter-form select, .contact-form input, .contact-form textarea { width: 100%; min-height: 48px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.pagination { display: flex; justify-content: center; margin-top: 20px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 6px; }
.pagination .page-numbers { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 700; }
.pagination .current { border-color: var(--blue); background: var(--blue); color: #fff; }

/* 教材ページ */
.ws-header { padding: 8px 0 12px; }
.ws-header h1 { font-size: clamp(22px, 5.6vw, 30px); line-height: 1.35; }
.ws-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ws-facts div { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; }
.ws-facts dt { color: var(--muted); font-size: 11px; font-weight: 700; }
.ws-facts dd { font-weight: 800; }
.ws-facts a { text-decoration: underline; text-underline-offset: 3px; }
.use-options { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.use-buttons { display: grid; gap: 10px; }
.use-note { margin-top: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.print-guide { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); }
.js .print-guide:not(.is-open) { display: none; }
.print-guide h3 { font-size: 17px; }
.print-lead { margin-top: 4px; font-size: 14px; }
.print-steps { counter-reset: step; display: grid; gap: 8px; margin-top: 10px; }
.print-steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 0 10px; align-items: start; }
.print-steps li::before { content: counter(step); grid-row: span 2; display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--blue); color: #fff; font-size: 15px; font-weight: 800; }
.print-steps strong { font-size: 15px; line-height: 1.5; }
.print-steps span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.print-tip { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--blue-soft); font-size: 13px; }
.print-links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.print-links a { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 8px; text-align: center; line-height: 1.3; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--blue-dark); font-size: 13px; font-weight: 700; }
.print-links a::after { content: "↗"; margin-left: 4px; font-size: 11px; }
.print-links a:hover { border-color: var(--blue); }
.print-small { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.ws-body { display: grid; gap: 16px; margin-top: 18px; }
.included-units h2 { font-size: 17px; }
.included-units ol { counter-reset: unit; margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.included-units li { counter-increment: unit; display: grid; grid-template-columns: 28px 1fr; gap: 0 8px; padding: 9px 12px; line-height: 1.5; }
.included-units li + li { border-top: 1px solid var(--line); }
.included-units li::before { content: counter(unit); color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.included-units li span { grid-column: 2; color: var(--muted); font-size: 13px; }
.ws-cover { max-width: 240px; margin-inline: auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.progress-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.progress-panel p { display: flex; flex-direction: column; line-height: 1.5; }
.progress-panel span { color: var(--muted); font-size: 12px; }
.progress-panel .btn { min-height: 44px; font-size: 14px; }
.progress-panel.is-done { border-color: var(--hs-line); background: var(--hs); }
.worksheet-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.worksheet-nav a { display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 8px 14px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); line-height: 1.35; }
.worksheet-nav a:hover { border-color: var(--blue); }
.worksheet-nav small { color: var(--muted); font-size: 11px; }
.worksheet-nav span { font-weight: 800; }
.ws-next { text-align: right; }
.back-to-list { margin-top: 14px; text-align: center; }
.back-to-list a { display: inline-flex; align-items: center; min-height: 44px; color: var(--blue-dark); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* 文章ページ・ブログ */
.prose-main { max-width: 760px; }
.entry-byline { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.entry-content { margin-top: 10px; font-size: 16px; line-height: 1.9; }
.entry-content > * + * { margin-top: 1em; }
.entry-content h2 { margin-top: 1.8em; padding-bottom: .3em; border-bottom: 3px solid var(--line); font-size: 21px; line-height: 1.4; }
.entry-content h3 { margin-top: 1.5em; font-size: 18px; }
.entry-content a { color: var(--blue-dark); text-decoration: underline; text-underline-offset: 3px; }
.entry-content ul, .entry-content ol { padding-left: 1.4em; list-style: revert; }
.entry-content img { border-radius: 12px; }
.post-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.post-list li + li { border-top: 1px solid var(--line); }
.post-list a { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.post-list a:hover { background: var(--blue-soft); }
.post-list span { color: var(--muted); font-size: 13px; line-height: 1.6; }
.post-list small { color: var(--muted); font-size: 12px; }
.contact-form { max-width: 720px; }
.contact-field { margin-bottom: 16px; }
.contact-field label { display: block; margin-bottom: 4px; font-weight: 700; }
.contact-field .required { color: #c0392b; }
.contact-consent { display: flex; align-items: flex-start; gap: 8px; }
.contact-consent input { width: auto; min-height: 0; margin-top: 7px; }
.button, .wp-element-button { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 10px 24px; border: 0; border-radius: 999px; background: var(--blue); color: #fff; font-weight: 800; cursor: pointer; }
.form-message { padding: 14px 16px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; }
.form-error { background: #fdecea; color: #a02b20; }
.ad-slot { margin: 24px auto; padding: 12px; text-align: center; }

/* フッター */
.site-footer { margin-top: 24px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-main { display: grid; gap: 12px; padding-block: 22px; }
.footer-brand { display: flex; flex-direction: column; }
.footer-brand span { color: var(--muted); font-size: 13px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 16px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.footer-bottom { padding: 12px 0 18px; color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 719px) {
  .menu-toggle { display: inline-flex; align-items: center; }
  .main-nav { display: none; }
  .main-nav.is-open { display: block; position: absolute; top: 60px; left: 12px; right: 12px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 12px 30px rgba(0, 0, 0, .12); }
  .main-nav.is-open ul { flex-direction: column; align-items: stretch; }
}
@media (min-width: 720px) {
  .header-inner { min-height: 64px; }
  .home-hero { padding-top: 40px; }
  .home-lead { font-size: 17px; }
  .grade-picker--home { gap: 18px 12px; margin-top: 26px; }
  .grade-group ul { gap: 12px; }
  .grade-btn { min-height: 76px; }
  .grade-short { font-size: 24px; }
  .grade-soon { font-size: 11px; }
  .grade-picker--strip { margin-inline: 0; padding-inline: 0; }
  .grade-picker--strip .grade-btn { min-height: 44px; }
  .grade-picker--strip .grade-short { font-size: 15px; }
  .home-points { padding-top: 36px; }
  .home-points ul { grid-template-columns: repeat(5, 1fr); }
  .home-points li:last-child { grid-column: auto; }
  .subject-tabs { margin-inline: 0; padding-inline: 0; }
  .subject-tab { flex: 0 0 auto; min-width: 96px; }
  .ws-main { grid-template-columns: 132px 1fr auto; grid-template-areas: "range names meta"; align-items: center; padding-left: 18px; }
  .ws-context { display: block; }
  .filter-form { grid-template-columns: 1.6fr 1fr 1fr auto; }
  .filter-form--simple { grid-template-columns: 1fr auto; }
  .use-options { padding: 20px; }
  .use-buttons { grid-template-columns: 1fr 1fr; }
  .print-guide { padding: 20px; }
  .print-links { grid-template-columns: repeat(3, 1fr); }
  .ws-body { grid-template-columns: 1fr 240px; align-items: start; }
  .footer-main { grid-template-columns: 1fr 2fr; align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .grade-btn:hover { transform: none; }
}
