@charset "utf-8";

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* テーマスタイル */
:root {
  --text-heading-1: 20px;
  --text-heading-2: 18px;
  --text-body: 16px;

  --main-color-blue: #39c;
  --main-color-beige: #b4b264;
  --main-color-red: #c33;
  --main-color-purple: #939;

  --color-answer: #e63e3e;
  --color-correct: #00a0dd;
  --color-incorrect: #ef7193;
}

@media screen and (max-width: 1080px) {
  :root {
    --text-heading-1: 20px;
    --text-heading-2: 18px;
    --text-body: 16px;
  }
}

/* 教科書別スタイル */
body[data-color-scheme='blue'] {
  --main-color: var(--main-color-blue);
  --sub-color: #f2f9ff;
  --header-text-color: white;
}

body[data-color-scheme='beige'] {
  --main-color: var(--main-color-beige);
  --sub-color: #fffef2;
  --header-text-color: white;
}

body[data-color-scheme='red'] {
  --main-color: var(--main-color-red);
  --sub-color: #fff5f4;
  --header-text-color: white;
}

body[data-color-scheme='purple'] {
  --main-color: var(--main-color-purple);
  --sub-color: #fdf5ff;
  --header-text-color: white;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* マーカー */
.marker.expand.md {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background-color: var(--main-color);
  box-shadow: 0 0 4px #0003;
  transition: transform 250ms cubic-bezier(0.45, 0.15, 0.85, 1);
}

.marker.expand.md::before,
.marker.expand.md::after {
  content: '';
  grid-row: 1;
  grid-column: 1;
  --size: 0.75rem;
  background-color: var(--header-text-color);
  transition: opacity 250ms linear;
}

.marker.expand.md::before {
  width: var(--size);
  height: 2px;
}

.marker.expand.md::after {
  width: 2px;
  height: var(--size);
}

.dropdown.open > summary .marker.expand {
  transform: rotate(90deg);
}

.dropdown.open > summary .marker.expand::before {
  opacity: 0;
}

/* トグルスイッチ */
.toggle-switch {
  --size: 2rem;

  /* 背景 */
  display: inline-block;
  position: relative;
  width: calc(var(--size) * 2);
  height: var(--size);

  appearance: none;
  background-color: #eee;
  border-radius: 9999px;
  box-shadow: inset 0 0 4px #0003;

  transition: background-color 250ms cubic-bezier(0.4, 0, 0, 1.15);

  cursor: pointer;
}
.toggle-switch-sm {
  --size: 1.5rem;
}

.toggle-switch:checked {
  background-color: var(--main-color);
}

.toggle-switch::after {
  /* つまみ */
  content: '';
  width: var(--size);
  height: var(--size);
  position: absolute;
  top: 0;
  left: 0;

  border-radius: 50%;
  background: white;
  box-shadow: 0px 0px 3px 1px #0004;

  transition: left 125ms cubic-bezier(0.4, 0, 0, 1.15);
}

.toggle-switch:checked::after {
  left: calc(100% - var(--size));
}
@media screen and (max-width: 920px) {
  .toggle-switch {
    --size: 1.8rem;
  }
  .toggle-switch-sm {
    /* toggle-switch を上書き */
    --size: 1.35rem;
  }
}

/* レイアウト */
html,
body {
  height: 100%;
  overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
  html,
  body {
    height: -webkit-fill-available;
  }
}

body {
  display: grid;
  grid-template-rows: max-content max-content 1fr max-content;
  grid-template-areas: 'header' 'navigation' 'contents' 'footer';

  background-color: white;
  color: #3a3a3a;

  font: 400 16px 'TT-UDDigiKyokashoPro-Medium', sans-serif;
  font-feature-settings: 'palt';
}

.page-header {
  grid-area: header;
  position: sticky;
  top: 0;
  left: 0;
  width: 100vw;
  z-index: 10000;
  box-shadow: 0 0 8px #0006;
  background-color: var(--main-color);
  color: var(--header-text-color);
}

.page-header .container {
  display: flex;
  align-items: center;
  max-width: 100%;
  min-height: 4rem;
}

.back-button,
#menu-toggle {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  max-width: 4rem;
  min-height: 4rem;
  flex-shrink: 0;

  padding: 0;
  border: none;
  background: none;

  font-size: 300%;
  text-decoration: none;
  transition: 75ms ease-out;

  cursor: pointer;
}

.back-button:hover,
#menu-toggle:hover {
  background-color: #fff3;
  filter: none;
}

/* 戻るボタン */
.back-button {
  border-right: solid 1px white;
  background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDMwIDIwIj48cGF0aCBkPSJNMTAsMCwwLDEwLDEwLDIwaDIuODI5bC05LTlIMzBWOUgzLjgyOGw5LTlaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIDApIiBmaWxsPSIjZmZmIi8+PC9zdmc+');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 2rem;
}

/* メニューボタン */
#menu-toggle {
  border-left: solid 1px white;
}

.page-header .title {
  flex: 1;
  padding: 0.25rem 1.5rem;
}

.page-header .title h1 {
  font-size: 14px;
  font-weight: normal;
  line-height: 1.15;
}

body[data-view-type='index'] .page-header .title h1 {
  font-size: 16px;
  padding-left: 0.5rem;
}

.page-header .title h2 {
  margin-top: 0.1rem;
  font-size: 16px;
  font-weight: normal;
  line-height: 1.15;
}

.menu-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #0006;
  z-index: 1;
  visibility: hidden;
  opacity: 0;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: calc(320px + env(safe-area-inset-right, 0));
  height: 100%;
  transform: translateX(100%);

  padding: 0 2rem 4rem;
  padding-right: calc(2rem + env(safe-area-inset-right, 0));
  border-left: solid 1px #0002;
  box-shadow: 0 0 36px #0002;
  background: var(--main-color);

  overflow-x: hidden;
  overflow-y: auto;
}

.menu-container,
.menu {
  transition: 350ms cubic-bezier(0.165, 0.84, 0.44, 1);
  transition-property: opacity, transform, visibility;
}

.menu-container.open {
  visibility: visible;
  opacity: 1;
}

.menu-container.open .menu {
  transform: translateX(0);
}

.menu-container #menu-close {
  display: flex;
  align-items: center;
  gap: 1rem;

  margin: 1rem 0;
  margin-left: auto;
  margin-right: -1rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  cursor: pointer;
  font-size: 110%;
  color: white;
}

.menu-container #menu-close:hover {
  background: #0001;
  text-decoration: underline dotted 2px currentColor;
}

.menu-container #menu-close img {
  filter: invert(1);
}

.menu-container .menu ul > li:not(:first-child) {
  margin-top: 1.5rem;
}

.menu-container .menu ul > li > a,
.menu-container .menu ul > li > button {
  display: block;
  width: 100%;
  padding: 1rem;

  border: solid 2px white;
  border-radius: 0.5rem;
  background: transparent;

  color: inherit;
  text-align: center;
  text-decoration: none;
  font-size: 1.15em;

  transition: 75ms ease-out;
  transition-property: color, background-color;
}

.menu-container .menu ul > li > a:hover,
.menu-container .menu ul > li > button:hover {
  background-color: white;
  color: var(--main-color);
}

.breadcrumbs {
  grid-area: navigation;
  background-color: var(--sub-color);
  font-size: 75%;
}

.breadcrumbs ol {
  display: flex;
  align-items: center;
  overflow-x: auto;
  list-style: none;
  line-height: 2;
}

.breadcrumbs ol li {
  position: relative;
  margin-top: 0;
  opacity: 0.65;
  padding: 0.35rem 1rem 0.2rem;
  flex-shrink: 0;
}

.breadcrumbs ol li:not(:first-child) {
  margin-left: 1.5rem;
}

.breadcrumbs ol li:not(:first-child)::before {
  content: '';
  display: block;
  width: 0.3rem;
  height: 0.3rem;
  position: absolute;
  top: calc(50% + 0.15em);
  left: -1rem;
  transform: translateY(-50%) rotate(-45deg);
  border-right: solid 2px;
  border-bottom: solid 2px;
  border-color: #0006;
}

.breadcrumbs ol li a {
  color: #0006;
  text-decoration: none;
  transition: color 75ms ease-out;
}

.breadcrumbs ol li a:hover {
  color: #000c;
}

main {
  grid-area: contents;
  width: 100%;
  overflow-y: auto;
  padding: 0 1rem;
  line-height: 1.8;
}

main .container {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

main .container .scroll-content {
  padding: 2.5rem 0;
}

.container.contents-list {
  height: fit-content;
}

.page-footer {
  grid-area: footer;
  z-index: 1;
  padding: 0;
  padding-left: calc(1.5rem + env(safe-area-inset-left, 0));
  padding-right: calc(1.5rem + env(safe-area-inset-right, 0));

  background-color: var(--main-color);
  box-shadow: 0 0 8px #0006;
  color: var(--header-text-color);
  text-align: right;
  font-size: 11px;
  line-height: 1.8;
}

/* Scroll to top */
button#scroll-to-top {
  position: fixed;
  width: 3.75rem;
  height: 3.75rem;
  right: 0.75rem;
  bottom: 1.75rem;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.25rem;

  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: #282828;

  color: #eee;
  font-size: 10px;
  line-height: 1.35;

  cursor: pointer;

  transition: 350ms cubic-bezier(0.165, 0.84, 0.44, 1);
  transition-property: filter, transform, visibility, opacity;
}

button#scroll-to-top:not(.active) {
  visibility: hidden;
  opacity: 0;
  transform: translateY(100%);
}

button#scroll-to-top:hover {
  filter: contrast(0.5) brightness(1.1);
}

/* Index Components */
.chapter {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  scroll-margin-top: 1rem;
}

.chapter-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;

  margin-bottom: 1rem;
  padding: 0.5rem 1.5rem;
  border-radius: 0.75rem;
  background-color: var(--main-color);

  font-weight: normal;
  font-size: var(--text-heading-1);
  color: var(--header-text-color);
}

.chapter-group-label {
  margin-bottom: 0.5rem;
  display: inline-block;
  padding-inline: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--main-color);
  font-size: var(--text-body);
  color: var(--main-color);
}

.dropdown-controls {
  display: flex;
  gap: 0.5rem;
}

.dropdown-controls button {
  cursor: pointer;
  width: 2.5rem;
  height: 2.5rem;

  padding: 0;
  border: solid 2px white;
  border-radius: 9999px;
  box-shadow: 0 1px 4px #0004;

  transition: transform 250ms cubic-bezier(0.45, 0.15, 0.85, 1);
}

.dropdown-controls button:hover {
  background-color: #0002;
}

.dropdown-controls button:active {
  background-color: #0006;
}

.dd-toggle {
  display: grid;
  place-items: center;
  background: transparent;
}

.dd-toggle::before,
.dd-toggle::after {
  content: '';
  grid-row: 1;
  grid-column: 1;
  --size: 1rem;
  background-color: var(--header-text-color);
  transition: opacity 250ms linear;
}

.dd-toggle::before {
  width: var(--size);
  height: 2px;
}

.dd-toggle::after {
  width: 2px;
  height: var(--size);
}

.dd-toggle[data-action='close'] {
  transform: rotate(90deg);
}

.dd-toggle[data-action='close']::before {
  opacity: 0;
}

.chapter-title ~ .group {
  margin-left: 1rem;
}

.group + .group {
  margin-top: 0.5rem;
}

.group-title {
  padding: 0.5rem 0.25rem;
  font-size: var(--text-heading-3);
}

.section + .section {
  margin-top: 0.75rem;
}

.section > .dropdown-content {
  overflow: hidden;
}

.section > .dropdown-content > .page-index {
  padding-left: 1rem;
}

.section:not(:last-child).open > .dropdown-content > .page-index {
  padding-bottom: 1.5rem;
}

.section > summary {
  list-style: none;
  /* <details>デフォルトの矢印を表示しない */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.section > summary::-webkit-details-marker {
  display: none;
}

.section:not(.open) + .section > summary > .section-title {
  /* 開いたセクションに続くセクションのタイトル */
  border-top: none;
}

.section > summary {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border: solid var(--main-color) 1px;
  border-radius: 0.5rem;
  background-color: var(--sub-color);
  transition: filter 25ms ease-out;
}

.section > summary:hover {
  filter: brightness(0.95);
}

.section-title {
  flex: 1;
  font-size: var(--text-heading-2);
  line-height: 1.2;
  font-weight: normal;
}

.section-title small {
  display: inline-block;
  margin: 0 0.5rem;
  opacity: 0.5;
  font-size: 75%;
  transform: translateY(1px);
  /* 微調整 for Firefox */
}

.section > summary .marker {
  flex-shrink: 0;
}

.page-index {
  list-style: none;
}

.section:not(:last-child).open > .dropdown-content > .page-index {
  padding-bottom: 1rem;
}

.page-block {
  border-bottom: solid 2px #ddd;
  font-size: 18px;
}

.page-block:not(:first-child) {
  border-top: none;
}

.section .page-block:first-child {
  border-top: none;
}

.page-block small {
  margin-left: 0.5rem;
  opacity: 0.5;
}

.page-block a {
  color: inherit;
  text-decoration: none;
}

.page-block > .page-link {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1rem 0.5rem;
  padding-left: 0.15rem;
  background-color: white;
  transition: filter 75ms linear;
  user-select: none;
}
.page-block .page-link-inner {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.page-block > .page-link .page-block-control {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.page-block > .page-link .page-block-control label {
  cursor: pointer;
}

.page-block .page-type-icon {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  opacity: 0.5;
}

@media screen and (max-width: 640px) {
  .page-block > .page-link.drill {
    flex-wrap: wrap;
  }
  .page-block > .page-link.drill .page-block-control {
    width: 100%;
  }
  .page-block > .page-link.drill .random-switch {
    border: none;
    padding-left: 3rem;
  }
}

.page-block > a.page-link:hover,
.page-block > .page-link:has(a:hover) {
  filter: brightness(0.975);
}
.page-block > a.page-link:hover .page-link-text,
.page-block > .page-link:has(a:hover) .page-link-text {
  text-decoration: underline dotted 3px var(--main-color);
}

.page-block > .page-link::before,
.page-block > .page-link::after {
  flex-shrink: 0;
}

.page-block > .page-link small {
  display: inline-block;
}

.page-block .page-description {
  padding-left: 2.75rem;
  padding-bottom: 0.75em;
}

.page-description {
  font-size: 0.85em;
  color: #000a;
}

/* ドリルランダム選択 */
.page-block .random-switch {
  gap: 0.75rem;
  padding-inline: 1rem;
  border-left: solid 1px #0003;
  color: var(--main-color);
  font-weight: medium;
}

/* ポップアップ */
.popups {
  position: fixed;
  z-index: 10001;
}

.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 3rem;
  background-color: #0008;

  opacity: 1;
  visibility: visible;
  transition: 150ms ease-out;
  transition-property: visibility, opacity;
}

.popup:not([data-open='true']) {
  visibility: hidden;
  opacity: 0;
}

.popup-content {
  position: relative;
  margin: auto;
  max-width: 640px;
  padding: 2.5rem;
  border-radius: 0.75rem;
  background-color: white;

  font-size: var(--text-body);
  line-height: 1.8;
  color: #3d3d3d;
}

.popup-content > p {
  margin-top: 1em;
}

.popup-content .close-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: solid 2px #0003;
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.popup-content .close-button img {
  display: block;
}

@media screen and (max-width: 920px), screen and (max-height: 920px) {
  body {
    font-size: 16px;
  }

  .page-header .title {
    padding: 0.25rem 0.55rem;
  }

  .breadcrumbs ol {
    margin: 0;
  }

  .breadcrumbs ol li {
    padding: 0.25rem 1rem 0.15rem;
  }

  .breadcrumbs ol li:not(:first-child) {
    margin-left: 0.5rem;
  }

  .breadcrumbs ol li:not(:first-child)::before {
    left: -0.5rem;
  }

  .chapter {
    margin-bottom: 1rem;
  }

  .chapter-title {
    padding: 0.3rem 1rem 0.35rem;
  }

  .chapter-title > p {
    padding-block: 0.125rem;
  }

  .chapter-title ~ .group {
    margin-left: 0;
    padding: 0 0.25rem;
  }

  .section + .section {
    margin-top: 0.6rem;
  }

  .section > summary {
    padding: 0.75rem 0.8rem;
  }

  .section > summary > .section-title {
    font-size: 16px;
  }

  .page-block {
    font-size: 16px;
  }

  .page-block > .page-link {
    padding: 0.8rem 0.5rem 0.75rem;
    gap: 0.5rem 1rem;
  }

  .page-block .page-type-icon {
    width: 2rem;
    height: 2rem;
  }

  .popup {
    padding: 1rem;
    overflow-y: scroll;
  }

  .popup-content {
    padding: 2rem;
  }
}

@media screen and (max-width: 920px) {
  .rest-reminder {
    position: fixed;
    left: calc(0.5rem + env(safe-area-inset-left));
    bottom: 0rem;
    height: 2.5rem;
    flex-direction: row-reverse;
    gap: 0.75rem;
    filter: drop-shadow(0 2px 2px #0003);
  }

  .rest-reminder .text-bubble {
    margin-right: 0;
    margin-bottom: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    filter: drop-shadow(0 0 4px #0002);
  }

  .rest-reminder .text-bubble::before {
    clip-path: polygon(0 0, 100% 100%, 100% 0);
    left: unset;
    right: 100%;
  }

  .rest-reminder .mascot-image {
    width: 2.5rem;
    height: 2.5rem;
    background-position-y: 0px;
  }

  .section > .dropdown-content > ol {
    padding: 0 0.25rem;
  }
}

/* 幅が狭い時 */
@media screen and (max-width: 640px) {
  .page-header .container {
    min-height: 3rem;
  }

  .back-button,
  #menu-toggle {
    max-width: 3rem;
    min-height: 3rem;
  }

  .section > .dropdown-content > .page-index {
    padding-left: 0.5rem;
  }

  .page-header .title h1 {
    font-size: 13px;
  }

  .page-header .title h2 {
    font-size: 15px;
  }

  .rest-reminder .text-bubble {
    font-size: 75%;
  }

  .page-footer {
    text-align: right;
    padding-left: calc(0.75em + env(safe-area-inset-left, 0));
    padding-right: calc(0.75em + env(safe-area-inset-right, 0));
  }
}
