/* === Yami Learning - Ocean Blue Affix Layout v4.0 === */

/* === 頁面基礎 === */
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans TC','Gentium Plus',sans-serif;
  background: linear-gradient(to right, #0077B6 0%, #A9D6E5 20%, #A9D6E5 80%, #0077B6 100%);
  color: #222;
  overflow-x: hidden;
}

/* === 頁首 Header === */
header {
  position: relative;
  width: 100%;
  height: 25vh;
  overflow: hidden;
}
header img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
header h1 {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 18px;
  border-radius: 10px;
  font-size: clamp(18px, 3vw, 28px); /* ✅ 自動縮放字體 */
  line-height: 1.3;                  /* ✅ 行距 */
  letter-spacing: 1px;
  text-align: center;
  font-family: "Noto Sans TC", "Noto Serif TC", sans-serif;
  font-weight: 700;
  word-wrap: break-word;             /* ✅ 自動換行 */
  white-space: normal;               /* ✅ 允許多行 */
  max-width: 90%;                    /* ✅ 防止太寬時溢出 */
}

/* ✨ 新增副標題樣式 */
header .subtitle {
  position: absolute;
  top: 58%;                      /* 副標題稍微往下 */
  left: 50%;
  transform: translateX(-50%);
  color: #8B0000;                /* 酒紅色文字 */
  font-weight: 600;
  font-size: 20px;
  font-family: 'Gentium Plus', 'Noto Sans TC', serif;
  background: rgba(255, 248, 230, 0.85); /* 淺米色透明底 */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  padding: 6px 16px;
  border-radius: 10px;
  letter-spacing: 1px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}
/* 補強橫線設計 */
header .subtitle::before,
header .subtitle::after {
  content: "—";
  color: #8B0000;
  font-weight: bold;
  margin: 0 0.5px;
}
/* === Header 語言切換與 Logo === */
.header-top {
  position: absolute;
  top: 10px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 5;
}
.lang-switch a {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  background: rgba(0, 51, 102, 0.4);
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.lang-switch a:hover {
  background: rgba(0, 51, 102, 0.7);
}
.teamlogo {
  height: 36px;
  width: auto;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
  background: rgba(255,255,255,0.3);
}

/* === 頂端紅線 === */
body::before {
  content: "";
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 8px;
  background-color: #aa0d2a;
  z-index: 1000;
}

/* === 主體排版 === */
.layout {
  display: flex;
  align-items: stretch;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 25vh);
}

/* === 側欄 Sidebar === */
.sidebar {
  flex: 0 0 220px;
  background: #023E8A;
  color: #fff;
  padding: 24px 16px;
  border-right: 3px solid #0077B6;
  overflow-y: auto;
}
.sidebar::before {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  background-color: #aa0d2a;
}
.sidebar h3 {
  border-bottom: 2px solid #00B4D8;
  padding-bottom: 6px;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.05em;
}
.sidebar a {
  color: #E0F7FA;
  text-decoration: none;
  font-weight: 600;
  display: block;
  padding: 6px 4px;
  border-radius: 4px;
  transition: all 0.25s ease;
}
.sidebar a:hover {
  background: rgba(0, 180, 216, 0.25);
  padding-left: 8px;
  color: #fff;
}

/* === 內容區 Content === */
.content {
  flex: 1;
  background: #fff;
  padding: 40px;
  line-height: 1.8;
  min-height: 60vh;
  overflow-y: auto;
}
.content h2 {
  color: #023E8A;
  border-bottom: 2px solid #0077B6;
  padding-bottom: 6px;
  margin-top: 0;
}

/* === Footer === */
footer {
  background: #002855;
  color: #E0F7FA;
  text-align: center;
  padding: 32px 10px;
  font-weight: 500;
  line-height: 1.6;
  position: relative;
}

/* 🔹 上方著作資訊 */
.footer-top {
  color: #ffffff;
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 0.95em;
}

.footer-top a {
  color: #ADE8F4;
  text-decoration: none;
  font-weight: 700;
}

.footer-top a:hover {
  color: #fff;
  text-decoration: underline;
}

/* 🔹 中間紅線 */
.footer-line {
  width: 90%;
  height: 5px;
  margin: 10px auto 14px;
  background: linear-gradient(to bottom, #bb0e2b, #660a15);
  border-radius: 3px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* 🔹 下方團隊資訊 */
.footer-bottom {
  color: #E0F7FA;
  font-size: 0.9em;
  line-height: 1.6;
}

.footer-bottom a {
  color: #ADE8F4;
  text-decoration: none;
  font-weight: 600;
}

.footer-bottom a:hover {
  color: #fff;
  text-decoration: underline;
}


/* === Iframe 內容區 === */
iframe {
  width: 100%;
  height: auto;
  min-height: 600px;
  border: none;
  background: #fff;
  display: block;
}

/* === 課文顯示樣式（達悟語與中文翻譯） === */
.speaker {
  color: #023E8A;
  font-weight: 700;
}
.sentence {
  color: #8B0000; /* 酒紅色達悟語 */
  font-weight: 600;
  font-family: 'Gentium Plus', serif;
}
.translation {
  color: #555;
  font-style: italic;
  font-size: 0.97em;
  margin-left: 1.5em;
}

/* === 對話卡片（Lesson對話） === */
.dialogue {
  background: #f9fbfd;
  border-left: 4px solid #0077B6;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: flex-start;
}
.play-btn {
  cursor: pointer;
  color: #0077B6;
  font-size: 1.3em;
  margin-right: 10px;
  background: #E0F7FA;
  border-radius: 50%;
  padding: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
}
.play-btn:hover {
  background: #00B4D8;
  color: #fff;
  box-shadow: 0 0 8px rgba(0,180,216,0.5);
  transform: scale(1.1);
}
audio {
  display: none;
}

/* === 手機版與自適應標題 === */

/* ✅ 通用調整：平板、手機橫向 */
@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 4px solid #0077B6;
  }

  .content {
    padding: 20px;
  }

  .header-top {
    top: 8px;
    right: 10px;
    gap: 8px;
  }

  /* ✨ 主標題自動縮放 (使用 clamp) */
  header h1 {
    font-size: clamp(18px, 3vw, 26px); /* 最小18px，最大26px，自動縮放 */
    padding: 6px 12px;
    line-height: 1.25;
    word-wrap: break-word;
    white-space: normal; /* 允許換行 */
    text-align: center;
    max-width: 90%;
  }

  /* ✨ 副標題跟隨調整 */
  header .subtitle {
    font-size: clamp(12px, 2vw, 18px);
    padding: 4px 10px;
    top: 62%; /* 下移一點避免壓到標題 */
  }
}

/* ✅ 手機直立模式 */
@media (max-width: 768px) {
  header h1 {
    font-size: clamp(16px, 4vw, 22px);
    padding: 5px 10px;
    line-height: 1.2;
    max-width: 92%;
  }

  header .subtitle {
    font-size: clamp(11px, 2.5vw, 16px);
    top: 64%;
    line-height: 1.3;
  }
}

/* ✅ 極小螢幕（小於 480px，例如舊手機） */
@media (max-width: 480px) {
  header h1 {
    font-size: clamp(14px, 5vw, 20px);
    padding: 4px 8px;
    line-height: 1.1;
  }

  header .subtitle {
    font-size: 10px;
    top: 65%;
  }
}

/* == Tabs（新增） == */
.lesson-tabs{
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: .5rem; padding: .5rem 0;
  background: #fff; border-bottom: 2px solid #0077B6;
}
.lesson-tabs [role="tab"]{
  border:1px solid #e5e7eb; padding:.4rem .8rem; border-radius:999px;
  background:#f9fafb; cursor:pointer; font-weight:600; color:#023E8A;
}
.lesson-tabs [role="tab"][aria-selected="true"]{
  background:#0077B6; color:#fff; border-color:#0077B6;
}
[role="tabpanel"]{ padding: 1rem 0; }
/* 建議加到 style.css 供三個分頁共用 */
.act p{margin:.5em 0}
.act h4{color:#023E8A;margin:1.2em 0 .4em}
.act ol{margin:.4em 0 .8em 1.2em}
.act ul{margin:.2em 0 .6em 1.2em}
.ex{margin:.4em 0 .8em .8em;padding-left:.8em;border-left:3px solid #e5e7eb}
.lx{color:#8B0000;font-weight:700;font-family:'Gentium Plus',serif}
.tr{color:#555;font-style:italic;display:block;margin-top:.15em}
.table-like{display:grid;grid-template-columns:1fr 1fr;gap:.6em}
.badge{display:inline-block;background:#eaf4ff;color:#023E8A;border:1px solid #cfe3ff;border-radius:999px;padding:.05em .5em;font-size:.85em;margin-left:.4em}
.note{color:#444;background:#f8fafc;border:1px solid #e5e7eb;border-left:4px solid #0077B6;border-radius:6px;padding:.6em .8em;margin:.8em 0}
  
}

/* 圖片自動縮放，不超出內容寬度 */
.media img{
  max-width: 50%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,.04);
}

/*（可選）限制示範活動裡的圖最大寬度為 680px */
#demo .media img{ max-width: 350px; }

/* 讓帶有 .media-left 的圖與文字靠左 */
.media-left{ text-align:left; margin-left:0; }
.media-left img{ display:block; margin:0; max-width:100%; height:auto; }
.media-left figcaption{ text-align:left; margin-top:.35rem; }

#demo .act{ padding-left:0; }  /* 可選，讓示範活動整塊更貼左 */


/* === 次級分頁（課文閱讀 / 文法 / 活動 ...） ============================ */
.subtabs{
  display:flex; gap:10px; align-items:center;
  padding:10px 12px; margin:12px 0 18px;
  background:rgba(255,255,255,.8);
  border-radius:12px;
  overflow:auto;               /* 手機可橫向滑動 */
  scrollbar-width:none;
  -webkit-overflow-scrolling: touch;
}
.subtabs::-webkit-scrollbar{ display:none; }

/* 放在內容白底容器內時更順眼 */
.content .subtabs{ margin-top: 0; }

.subtabs a{
  flex:0 0 auto;
  padding:8px 14px;
  border:1px solid #0b5d8f33;
  border-radius:999px;
  background:#ffffffaa;
  text-decoration:none;
  color:#0b3d6e;
  font-weight:700;
  line-height:1;
  box-shadow:0 1px 0 rgba(0,0,0,.04);
  transition:.18s ease;
  white-space:nowrap;
}
.subtabs a:hover{
  transform:translateY(-1px);
  box-shadow:0 6px 14px rgba(0,0,0,.08);
}

/* 目前頁：白底＋酒紅色下緣線 */
.subtabs a.active{
  background:#fff;
  border-color:#d6e9f7;
  box-shadow:0 8px 20px rgba(0,0,0,.10);
  position:relative;
}
.subtabs a.active::after{
  content:"";
  position:absolute; left:14px; right:14px; bottom:-7px;
  height:3px; border-radius:3px;
  background:#800020;          /* 酒紅色底線 */
}

/* RWD 微調 */
@media (max-width:720px){
  .subtabs{ padding:8px; gap:8px; }
  .subtabs a{ padding:8px 12px; font-weight:600; }
}
 
