/* ------------------------------
Foundation（変数・リセット・ベース）
------------------------------ */
:root {
  --orange: #f47720;
  --orange-dark: #d35f12;
  --orange-red: #ff5a3d;
  --green: #08b45d;
  --blue: #23a8e0;
  --yellow: #fff69b;
  --marker: #fff459;
  --ink: #050505;
  --white: #ffffff;
  font-family:
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    Meiryo,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--white);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ------------------------------
レイアウト（ポータル全体・ヘッダー）
------------------------------ */
.portal {
  display: grid;
  width: 100%;
  min-height: 100svh;
  /* 1画面に収まる時はマップエリアが画面を満たし、収まらない時は伸びてページスクロールで全要素を見せる。
      minmax(0,1fr)+overflow:hidden だと下段（必須のボタン等）が見切れるため 1fr にして切り取らない */
  grid-template-rows: auto 1fr;
  /* 横方向の背景マップは .portal-map 側の overflow:hidden で内包される */
  overflow-x: hidden;
  background: var(--white);
}

.portal-header {
  display: grid;
  min-height: clamp(112px, 20.5svh, 156px);
  grid-template-columns: minmax(144px, 21vw) 1fr;
  align-items: center;
  gap: clamp(10px, 2vw, 32px);
  padding: clamp(10px, 2svh, 18px) clamp(26px, 5vw, 72px) clamp(12px, 2svh, 20px) clamp(22px, 5vw, 72px);
  background: var(--white);
}

.portal-logo {
  width: clamp(128px, 17.6vw, 192px);
  padding-top: 0;
}

.portal-logo img {
  width: 100%;
  height: auto;
}

/* ------------------------------
イントロコピー
------------------------------ */
/* 見出し・ボタン・コピー共通の日本語フォント */
.intro-copy,
.region-title,
.online-title,
.region-link,
.main-copy {
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
}

.intro-copy {
  padding-top: 6px;
  text-align: center;
  font-size: clamp(14px, 1.66vw, 22px);
  font-weight: 900;
  line-height: 1.7;
}

.intro-copy p {
  margin: 0;
}

.custom-mark.custom-half-marker {
  position: relative;
  z-index: 0;
  display: inline-block;
  padding: 0 2px;
}

.custom-mark.custom-half-marker::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  bottom: 0.05em;
  height: 0.38em;
  background: var(--marker);
}

/* ------------------------------
マップエリア（背景・グリッド配置）
------------------------------ */
/* main（マップ）と footer をまとめる黄色キャンバス。
   背景（黄色＋装飾＋世界地図）をこの層に持たせ、フッター下端まで背景を連続させる。 */
.portal-canvas {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 53% 46%, rgba(255, 255, 255, 0.78) 0 17%, rgba(255, 255, 255, 0) 38%),
    var(--yellow);
}

.portal-map {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: clamp(24px, 6svh, 56px) clamp(26px, 5vw, 72px) clamp(20px, 4svh, 44px);
  /* 基本150px。5列が収まらない狭い幅ではグリッドの列幅に合わせて縮小 */
  --card-width: min(150px, calc((100vw - 2 * clamp(26px, 5vw, 72px) - 4 * clamp(14px, 1.8vw, 28px)) / 5));
  --flag-width: clamp(17px, 2.06vw, 28px);
}

.world-map {
  position: absolute;
  left: 50%;
  top: 10.6%;
  width: max(109.8%, 760px);
  height: auto;
  max-width: none;
  transform: translateX(-50%);
  opacity: 0.95;
  pointer-events: none;
}

/* 横5分割（東アジア=3,4列目を合体）× 縦2行のグリッド */
.map-content {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100%;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  /* 2行目を余白ごと伸ばし、スローガンをエリア下端に寄せる */
  grid-template-rows: auto 1fr;
  column-gap: clamp(14px, 1.8vw, 28px);
  row-gap: clamp(24px, 5svh, 48px);
}

.region-europe {
  grid-column: 1;
}

.region-south {
  grid-column: 2;
}

.region-east {
  grid-column: 3 / 5;
}

.region-oceania {
  grid-column: 5;
}

.online-group {
  grid-column: 3 / 5;
  grid-row: 2;
}

/* ------------------------------
スローガングループ（ボタン＋コピー）
------------------------------ */
/* ボタン（上）とスローガン（下）を1マスに重ねず、flex縦積みで衝突を防ぐ。
    オンライン教室と同じ帯（row2）の左カラムに収めて1画面設計を維持する */
.slogan-group {
  grid-column: 1 / 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 5svh, 48px);
}

.portal-slogan {
  /* 上のボタンとの間を可変余白で埋め、常にエリア下端へ寄せる */
  margin-top: auto;
}

/* ------------------------------
地区誘導ボタン
------------------------------ */
/* 各地区トップへの誘導ボタン（白地＋地区カラーの枠線・文字・矢印） */
.region-links {
  /* 幅を内容（広い方のボタン）に合わせ、2つのボタンを同じ幅に揃える */
  display: grid;
  width: fit-content;
  max-width: 100%;
  gap: clamp(10px, 1.8svh, 16px);
  align-content: start;
}

.region-link {
  /* --btn-color を切り替えるだけで 枠線／文字／矢印／ホバー塗り が連動する */
  --btn-color: var(--orange);
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 2px solid var(--btn-color);
  background: rgba(255, 255, 255, 0.92);
  color: var(--btn-color);
  font-size: clamp(14px, 1.5vw, 21px);
  font-weight: 700;
  line-height: 1.3;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

.region-link.is-orange {
  --btn-color: var(--orange);
}

.region-link.is-blue {
  --btn-color: var(--blue);
}

.region-link.is-green {
  --btn-color: var(--green);
}

.region-link.is-red {
  --btn-color: var(--orange-red);
}

.region-link-text {
  flex: 1;
  align-self: center;
  padding: clamp(12px, 2.4svh, 18px) clamp(14px, 1.6vw, 22px);
}

.region-link-arrow {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding-right: clamp(12px, 1.4vw, 20px);
}

.region-link-arrow::before {
  content: "";
  width: clamp(18px, 1.7vw, 24px);
  height: clamp(18px, 1.7vw, 24px);
  /* 矢印色は文字色（currentColor）に追従。ホバーで白に切り替わる */
  background-color: currentColor;
  /* 右向き矢印（episフッターの arrow_right_alt 相当） */
  mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23000'%20stroke-width='2.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4%2012h15M13%206l6%206-6%206'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ホバー：地区カラーで塗りつぶし、文字・矢印を白に反転 */
.region-link:hover,
.region-link:focus-visible {
  background: var(--btn-color);
  color: var(--white);
}

@media (prefers-reduced-motion: reduce) {
  .region-link {
    transition: none;
  }
}

/* ------------------------------
地区・オンライン見出し（帯）
------------------------------ */
.region-title,
.online-title {
  min-height: clamp(34px, 5.8svh, 52px);
  color: var(--white);
  font-weight: 900;
  line-height: 1;
  margin: 0;
}

.region-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 0.92vw, 14px);
  font-size: clamp(15px, 1.72vw, 23px);
  background: var(--orange);
}

.region-title::before {
  content: "";
  width: clamp(14px, 2.1vw, 24px);
  height: clamp(14px, 2.1vw, 24px);
  background: url("/themes/portal/images/icon_go.svg") center / contain no-repeat;
}

.region-title.europe {
  background: var(--orange-red);
}

.region-title.east-asia,
.online-title {
  background: var(--green);
}

.region-title.oceania {
  background: var(--blue);
}

/* ------------------------------
教室カード
------------------------------ */
.campus-list {
  display: grid;
  justify-content: center;
  justify-items: center;
  gap: 18px;
  margin-top: clamp(14px, 3.65svh, 28px);
}

/* 東アジア・オンラインは2列グリッド（他は縦積み）。レイアウトはsectionの固有クラスで決定 */
.region-east .campus-list,
.online-group .campus-list {
  grid-template-columns: repeat(2, var(--card-width));
  justify-items: normal;
  gap: clamp(14px, 3.25svh, 28px) clamp(10px, 1.37vw, 20px);
}

.campus-link {
  display: block;
  width: var(--card-width);
}

.campus-card {
  width: 100%;
  margin: 0;
  color: #111;
  text-align: center;
}

.campus-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background:
    linear-gradient(135deg, rgba(35, 168, 224, 0.28), rgba(244, 119, 32, 0.22)),
    #d9eef2;
}

.campus-photo img:not(.flag) {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.campus-card figcaption {
  margin-top: 6px;
  font-size: clamp(11px, 1.37vw, 17px);
  font-weight: 900;
  line-height: 1.3;
  white-space: nowrap;
}

.flag {
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 1;
  width: var(--flag-width);
  height: calc(var(--flag-width) * 0.667);
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* ------------------------------
オンライン教室
------------------------------ */
.online-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 0.92vw, 14px);
  font-size: clamp(15px, 1.72vw, 23px);
}

.online-title::before {
  content: "";
  width: clamp(20px, 2.2vw, 30px);
  height: clamp(20px, 2.2vw, 30px);
  background: url("/themes/portal/images/icon_online.svg") center / contain no-repeat;
}

.online-list {
  /* 東アジアと同じ2列グリッド・同じgapで列位置を揃える */
  display: grid;
  grid-template-columns: repeat(2, var(--card-width));
  justify-content: center;
  gap: clamp(14px, 3.25svh, 28px) clamp(10px, 1.37vw, 20px);
  margin-top: clamp(13px, 3.05svh, 24px);
}

.online-list .campus-card figcaption {
  font-size: clamp(10px, 1.26vw, 15px);
}

/* ------------------------------
スローガンのコピー
------------------------------ */
.future-copy {
  /* 帯は文字量に合わせて伸縮させ、はみ出しを防ぐ */
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: clamp(10px, 2.44svh, 18px) clamp(14px, 1.6vw, 24px) clamp(9px, 2.03svh, 16px);
  background: rgba(255, 255, 255, 0.92);
  color: var(--orange);
  font-family: "Comic Sans MS", "Hiragino Maru Gothic ProN", cursive;
  font-size: clamp(13px, 1.6vw, 20px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.main-copy {
  display: inline-grid;
  min-height: clamp(48px, 8.39svh, 74px);
  margin: clamp(6px, 1.22svh, 12px) 0 0;
  place-items: center;
  background: rgba(255, 255, 255, 0.94);
  padding: 0 clamp(15px, 1.72vw, 26px);
  color: #ec742e;
  font-size: clamp(28px, 3.32vw, 46px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

/* ------------------------------
レスポンシブ：タブレット（761〜899px）
------------------------------ */
/* タブレット幅ではボタンを地図の先頭に全幅（2列）で移動し、オンライン教室との近接を解消 */
@media (min-width: 761px) and (max-width: 899px) {
  .map-content {
    grid-template-rows: auto auto 1fr;
  }

  /* ラッパーを透過させ、ボタン／スローガンを直接グリッドに配置し直す */
  .slogan-group {
    display: contents;
  }

  .portal-slogan {
    margin-top: 0;
  }

  .region-links {
    grid-column: 1 / -1;
    grid-row: 1;
    align-self: start;
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: clamp(10px, 1.8vw, 16px);
    margin-bottom: clamp(8px, 1.5svh, 16px);
  }

  .region-europe {
    grid-column: 1;
    grid-row: 2;
  }

  .region-south {
    grid-column: 2;
    grid-row: 2;
  }

  .region-east {
    grid-column: 3 / 5;
    grid-row: 2;
  }

  .region-oceania {
    grid-column: 5;
    grid-row: 2;
  }

  .online-group {
    grid-column: 3 / 5;
    grid-row: 3;
  }

  .portal-slogan {
    grid-column: 1 / 3;
    grid-row: 3;
  }

  /* 左カラム（2列分）に収まるようキャッチコピーを縮小し、右のサムネイルへのはみ出しを防ぐ */
  .main-copy {
    font-size: clamp(20px, 3vw, 30px);
  }
}

/* ------------------------------
レスポンシブ：スマートフォン（〜760px）
------------------------------ */
@media (max-width: 760px) {
  .portal {
    width: 100%;
    min-height: 100svh;
    overflow: visible;
  }

  .portal-header {
    min-height: auto;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 10px;
    padding: 18px 18px 22px;
  }

  .portal-logo {
    width: 128px;
  }

  .intro-copy {
    width: 100%;
    max-width: calc(100vw - 36px);
    padding-top: 0;
    font-size: clamp(14px, 3.9vw, 18px);
    line-height: 1.65;
  }

  .intro-copy p {
    overflow-wrap: anywhere;
  }

  .portal-map {
    min-height: auto;
    padding: 30px 18px 26px;
  }

  .world-map {
    top: 42px;
    width: 980px;
    opacity: 0.42;
  }

  /* ラッパーを透過させ、ボタン／スローガンを直接グリッドに配置し直す */
  .slogan-group {
    display: contents;
  }

  .region,
  .online-group,
  .region-links,
  .portal-slogan {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
  }

  .region-link {
    width: 100%;
  }

  /* SPではボタンを地図の先頭（各教室より上）に移動し、全幅で縦積み */
  .region-links {
    order: -1;
    /* 直後の見出しと混同しないよう、ボタン下に余白を確保 */
    margin-bottom: 18px;
  }

  .map-content {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 18px;
  }

  .region-title,
  .online-title {
    min-height: 40px;
  }

  .campus-list,
  .online-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 12px;
    justify-items: center;
  }

  .region-east .campus-list,
  .online-group .campus-list,
  .online-list,
  .region-oceania .campus-list {
    width: min(100%, 314px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-inline: auto;
  }

  .campus-link {
    /* 2列グリッド（314px幅・gap 14px）の列幅=150pxに全カード統一 */
    width: min(100%, 150px);
  }

  .campus-card figcaption {
    white-space: normal;
  }

  .portal-slogan {
    display: grid;
    gap: 6px;
    justify-items: start;
    margin-top: 4px;
  }

  .future-copy {
    width: auto;
    font-size: 13px;
    white-space: normal;
  }

  .main-copy {
    min-height: 48px;
    font-size: clamp(23px, 7vw, 29px);
    white-space: normal;
  }
}

/* ------------------------------
レスポンシブ：スマートフォン（〜480px）
------------------------------ */
@media (max-width: 480px) {
  .portal-logo {
    width: 110px;
  }

  .intro-copy {
    max-width: min(calc(100vw - 36px), 340px);
    font-size: 14px;
  }
}

/* ------------------------------
404ページ
------------------------------ */
/* 404はロゴだけのヘッダーなので白帯を作らず、ヘッダーごとキャンバス（黄色）に含める。
    .portal 直下の子が .portal-canvas だけになるため 1行グリッドにする */
.portal-error {
  grid-template-rows: 1fr;
}

.portal-error .portal-header {
  /* 世界地図（position:absolute）より前面に出す */
  position: relative;
  z-index: 1;
  /* トップの min-height は1画面設計のための高さ確保。404では中身の高さに任せて詰める */
  min-height: 0;
  background: transparent;
}

/* 教室カードのグリッドを持たないため、キャンバス内で縦横中央に寄せる。
    中身は justify-content で中央寄せするため、縦パディングは最低限の余白として svh で詰める
    （トップページと同じ値にするとフッターが1画面に収まらない） */
.error-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 3svh, 40px) clamp(26px, 5vw, 72px) clamp(16px, 2.5svh, 32px);
  text-align: center;
}

/* 見出し・ボタンの日本語フォント（.intro-copy 等と同じ指定） */
.error-code,
.error-status,
.error-title,
.error-home {
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
}

.error-code {
  /* 横幅基準で拡大しつつ、横向きスマホなど画面が低い時は svh 側で抑えて1画面に収める */
  margin: 0;
  color: var(--orange);
  font-size: clamp(64px, min(13vw, 20svh), 160px);
  font-weight: 900;
  line-height: 1;
}

.error-status {
  margin: clamp(2px, 0.6svh, 8px) 0 0;
  color: var(--orange);
  font-size: clamp(20px, 3.2vw, 40px);
  font-weight: 900;
  line-height: 1.2;
}

.error-title {
  margin: clamp(14px, 3svh, 28px) 0 0;
  font-size: clamp(17px, 2.1vw, 26px);
  font-weight: 900;
  line-height: 1.5;
}

.error-message {
  /* 背景の黄色が濃いため、本文も body の太字（700）を維持して沈まないようにする */
  margin-top: clamp(10px, 2svh, 18px);
  font-size: clamp(13px, 1.4vw, 16px);
  font-weight: 700;
  line-height: 1.8;
}

.error-message p {
  margin: 0;
}

/* 地区誘導ボタン＋ホームへ戻るボタン。
    .region-links は .map-content のグリッド前提の上書きを持つため流用せず、専用の器にする */
.error-links {
  /* SP幅でのボタン幅の上限。全幅の細長いボタンになるのを防ぐ */
  --btn-max: 440px;
  --btn-gap: clamp(10px, 1.8svh, 16px);
  display: grid;
  /* ラベルはカスタムフィールドで変更されるため、固定値ではなく内容幅で決める。
      SP以外はこの fit-content でラベルが折り返さない幅になる（文字量が変わっても追従する）。
      短いラベルだけになった場合に間延びしないよう --btn-max を下限にする */
  width: fit-content;
  min-width: min(var(--btn-max), 100%);
  max-width: 100%;
  margin-top: clamp(22px, 4.5svh, 40px);
  gap: var(--btn-gap);
  /* .error-main の text-align:center を打ち消す。ボタンのラベルは左寄せ＋矢印右端にする
      （中央寄せだと矢印との間が空いて間延びする。ポータルトップと同じ見え方に揃える） */
  text-align: left;
}

/* 地区ボタン2つ。同じ役割の並列選択なので、広い画面では横並びにして縦の積み上がりを抑える */
.error-region-links {
  display: grid;
  gap: var(--btn-gap);
}

/* ホームへ戻るは地区ボタン（白地・枠線）と役割が違うため、塗りで区別する */
.error-home {
  display: grid;
  place-items: center;
  /* 地区ボタンとは別の操作なので、gap に加えて余白を足して区切りを明確にする */
  margin-top: clamp(8px, 1.8svh, 18px);
  padding: clamp(12px, 2.4svh, 18px) clamp(20px, 2.4vw, 32px);
  border: 2px solid var(--orange);
  background: var(--orange);
  color: var(--white);
  font-size: clamp(14px, 1.5vw, 21px);
  font-weight: 700;
  line-height: 1.3;
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
}

.error-home:hover,
.error-home:focus-visible {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
}

@media (prefers-reduced-motion: reduce) {
  .error-home {
    transition: none;
  }
}

/* 2つ横に並べても折り返さない幅から横並びにする（トップの5列レイアウトと同じ 900px 境界） */
@media (min-width: 900px) {
  /* 2列とも「長い方のラベルが折り返さない幅」に揃う（親が fit-content のため 1fr が内容幅で解決される） */
  .error-region-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* 地区ボタン2つ分の幅いっぱいだと大きすぎるため、下段中央に控えめな幅で置く */
  .error-home {
    width: min(100%, 360px);
    justify-self: center;
  }
}

@media (max-width: 760px) {
  .error-main {
    padding: 30px 18px 26px;
  }

  /* SPはラベルの折り返しを許容し、--btn-max を上限に全幅で押しやすくする */
  .error-links {
    width: min(var(--btn-max), 100%);
  }
}

/* ------------------------------
アクセシビリティ（視覚的非表示・フッター）
------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.portal-footer {
  position: relative;
  padding: clamp(8px, 1.4svh, 16px) clamp(26px, 5vw, 72px);
  text-align: right;
}

.portal-footer small {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink);
}

/* コピーライトは SP 幅で中央寄せ（基底の右寄せを上書きするため base 定義より後に配置） */
@media (max-width: 760px) {
  .portal-footer {
    text-align: center;
  }
}
