/* ===========================================================
   site.css — web reader chrome for boat-ev-manual (screen only)
   Layers on top of style.css. Print hides all chrome.
   Brand colors: #16B4F2 · #0A5573 · #E4F2F1 · #8CD918 · #F2A516
   =========================================================== */

:root{
    --nav-w:286px;
    --bg:#E4F2F1;
    --chrome:#0A5573;
    --chrome-2:#083d52;
    --chrome-line:#1a6a8a;
    --accent-web:#16B4F2;
    --accent-green:#8CD918;
    --accent-gold:#F2A516;
    --txt-soft:#cfcfcf;
}

html{ scroll-behavior:smooth; }
body{ margin:0; }
.skip-to-content{
    position:fixed; top:-100px; left:50%; transform:translateX(-50%); z-index:200;
    background:var(--accent-web); color:#fff; padding:12px 24px; border-radius:0 0 12px 12px;
    font-weight:700; font-size:14px; text-decoration:none;
    box-shadow:0 4px 16px rgba(0,0,0,.3);
}
.skip-to-content:focus{ top:0; }

/* ---------- top bar ---------- */
#topbar{
    position:fixed; top:0; left:0; right:0; height:54px; z-index:80;
    display:flex; align-items:center; gap:12px; padding:0 14px;
    background:var(--chrome); color:#fff;
    box-shadow:0 2px 10px rgba(0,0,0,.25);
}
#topbar .tb-brand{ font-weight:800; font-size:15px; white-space:nowrap; color:#fff; text-decoration:none; }
#topbar .tb-brand:hover{ color:#fff; opacity:.85; }
#topbar .tb-brand small{ display:block; font-weight:400; font-size:10.5px; color:#9ac9d6; }
#nav a.navhome{ font-weight:700; }
#nav a.navhome .num{ background:transparent; font-size:16px; }
#topbar .tb-spacer{ flex:1; }
#topbar .tb-count{ font-size:13px; color:#b0d4de; white-space:nowrap; }
#menuBtn{
    display:inline-flex; align-items:center; justify-content:center;
    width:40px; height:40px; border:none; border-radius:10px;
    background:var(--chrome-2); color:#fff; cursor:pointer; flex:none;
}
#menuBtn:hover{ background:#0c4a64; }

/* inline SVG icons */
.ic{ width:18px; height:18px; display:inline-block; vertical-align:middle; flex:none; }
#nav a .num .ic{ width:17px; height:17px; }
#nav a .chk .ic, .card .cdone .ic{ width:16px; height:16px; }
.tb-icon{
    width:40px; height:40px; border:none; border-radius:10px;
    background:var(--chrome-2); color:#fff; font-size:17px; cursor:pointer; flex:none;
    display:inline-flex; align-items:center; justify-content:center; text-decoration:none;
}
.tb-icon:hover{ background:#0c4a64; }

/* search */
#searchWrap{ position:relative; }
#search{
    width:190px; max-width:42vw; height:38px; border:none; border-radius:9px;
    background:var(--chrome-2); color:#fff; padding:0 12px; font:inherit; font-size:13.5px;
}
#search::placeholder{ color:#8ab8c7; }
#search:focus{ outline:2px solid var(--accent-web); background:#0c4a64; }
#results{
    position:absolute; top:46px; right:0; width:340px; max-width:86vw;
    background:#fff; color:#111; border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.3);
    max-height:60vh; overflow:auto; display:none; z-index:90;
}
#results.show{ display:block; }
#results a{ display:block; padding:9px 13px; text-decoration:none; color:#111; border-bottom:1px solid #eee; font-size:13.5px; }
#results a:hover{ background:#f0f7fa; }
#results a b{ color:var(--accent-web); }
#results .none{ padding:12px 13px; color:#888; font-size:13px; }

/* ---------- progress bar ---------- */
#progbar{ position:fixed; top:54px; left:0; right:0; height:4px; background:rgba(255,255,255,.3); z-index:79; }
#progbar > span{ display:block; height:100%; width:0; background:var(--accent-green); transition:width .3s; }

/* ---------- sidebar nav ---------- */
#nav{
    position:fixed; top:58px; left:0; width:var(--nav-w); bottom:0;
    overflow-y:auto; background:var(--chrome); color:#e8e8e8;
    padding:10px 0 40px; z-index:70;
}
#nav .sep{ height:1px; background:var(--chrome-line); margin:6px 14px 8px; }
#nav a{
    display:flex; gap:9px; align-items:flex-start; padding:9px 16px;
    color:var(--txt-soft); text-decoration:none; font-size:13.5px; line-height:1.4;
    border-left:3px solid transparent;
}
#nav a .num{
    flex:0 0 24px; height:22px; border-radius:6px; background:var(--chrome-2);
    color:#cfcfcf; font-weight:700; font-size:12.5px; text-align:center; line-height:22px;
}
#nav a .num.navico{ display:inline-flex; align-items:center; justify-content:center; }
#nav a .lbl{ flex:1; }
#nav a .chk{ flex:none; color:var(--accent-green); font-weight:800; opacity:0; }
#nav a.done .chk{ opacity:1; }
#nav a.done .num{ background:var(--accent-green); color:#fff; }
#nav a:hover{ background:var(--chrome-2); color:#fff; }
#nav a.active{ background:#0c4a64; color:#fff; border-left-color:var(--accent-web); }
#nav a.active .num{ background:var(--accent-web); color:#fff; }
#nav .navfoot{ padding:12px 16px 0; }
#nav .navfoot a{ display:inline-flex; align-items:center; gap:7px; border-left:none; padding:8px 0; color:#9ac9d6; font-size:13px; }

#backdrop{ display:none; }

/* ---------- main column ---------- */
main{ margin-left:var(--nav-w); padding-top:58px; background:var(--bg); min-height:100vh; }

/* collapsible sidebar (desktop): toggled by #menuBtn, persisted in localStorage */
@media (min-width:881px){
    #nav{ transition:transform .22s ease; }
    main{ transition:margin-left .22s ease; }
    body.nav-collapsed #nav{ transform:translateX(-100%); }
    body.nav-collapsed main{ margin-left:0; }
    body.nav-collapsed .wrap{ max-width:1100px; }
}
.wrap{ max-width:1000px; margin:0 auto; padding:6px 10px 60px; }

/* prev / next */
.pn{ display:flex; gap:10px; max-width:794px; margin:14px auto 0; }
.pn a, .pn span{
    flex:1; padding:13px 16px; border-radius:12px; text-decoration:none;
    background:#fff; color:#111; box-shadow:0 2px 10px rgba(0,0,0,.08);
    font-size:14px; font-weight:600;
}
.pn .nx{ text-align:right; }
.pn a small{ display:block; font-weight:400; font-size:11.5px; color:#888; }
.pn a:hover{ box-shadow:0 4px 16px rgba(0,0,0,.14); }
.pn .disabled{ opacity:.4; pointer-events:none; }

/* buttons */
.donebar{ max-width:794px; margin:14px auto 0; text-align:center; }
.btn{
    display:inline-flex; align-items:center; justify-content:center; gap:7px;
    border:none; border-radius:10px; padding:11px 20px; font:inherit; font-weight:700;
    cursor:pointer; font-size:14px;
}
.btn-primary{ background:var(--accent-web); color:#fff; }
.btn-primary:hover{ background:#0f9ad4; }
.btn-ghost{ background:#fff; color:#111; box-shadow:0 2px 8px rgba(0,0,0,.08); }

/* ---------- interactive worksheet inputs ---------- */
input.ix, textarea.ix{
    font:inherit; font-size:15px; color:#0b3d36;
    background:#fffef6; border:none; border-bottom:1.6px solid #111;
    padding:6px 4px; width:100%; border-radius:0; min-height:44px;
}
input.ix:focus, textarea.ix:focus{ outline:none; background:#fff7cf; border-bottom-color:var(--accent-web); }
.ix-fill{ display:inline-block; width:auto; min-width:64px; }
td input.ix{ border-bottom:none; min-height:24px; }
.res .cell input.ix{ border-bottom:1.6px solid #111; }
.print-ws{ margin:4px 0 0; }

/* ---------- quiz ---------- */
.quiz{
    max-width:794px; margin:16px auto 0; background:#fff; border-radius:14px;
    box-shadow:0 2px 12px rgba(0,0,0,.08); padding:16px 18px;
}
.quiz h2{ margin:0 0 4px; font-size:18px; color:#0A5573; }
.quiz .lead{ margin:0 0 12px; font-size:13px; color:#777; }
.qitem{ border-top:1px solid #eee; padding:13px 0; }
.qitem:first-of-type{ border-top:none; }
.qitem .qq{ font-weight:700; margin:0 0 9px; font-size:14.5px; }
.qopt{
    display:block; width:100%; text-align:left; margin:6px 0; padding:10px 13px;
    border:1.6px solid #dcdcdc; border-radius:10px; background:#fafafa; cursor:pointer;
    font:inherit; font-size:14px; transition:.12s;
}
.qopt:hover{ border-color:var(--accent-web); }
.qopt.correct{ border-color:var(--accent-green); background:#f2fbe6; }
.qopt.wrong{ border-color:#c0392b; background:#fbeae8; }
.qopt:disabled{ cursor:default; }
.qfb{ margin:8px 0 0; font-size:13px; padding:8px 12px; border-radius:8px; display:none; }
.qfb.show{ display:block; }
.qfb.ok{ background:#f2fbe6; color:#3d6b0e; }
.qfb.no{ background:#fbeae8; color:#7a241b; }
.quiz .score{ margin-top:14px; font-weight:700; font-size:15px; color:#0A5573; text-align:center; display:none; }
.quiz .score.show{ display:block; }

/* ---------- glossary tooltip ---------- */
.term{
    border-bottom:1.5px dotted var(--accent-web); cursor:help; position:relative;
}
.term:hover, .term:focus{ background:#dff0f8; }
.term .tip-pop{
    position:absolute; left:0; bottom:130%; z-index:50;
    width:max-content; max-width:280px; background:#0A5573; color:#fff;
    padding:8px 11px; border-radius:9px; font-size:12.5px; line-height:1.5; font-weight:400;
    box-shadow:0 6px 20px rgba(0,0,0,.3); opacity:0; pointer-events:none; transition:.12s;
}
.term .tip-pop b{ color:#8CD918; }
.term:hover .tip-pop, .term:focus .tip-pop{ opacity:1; }

/* ---------- landing page ---------- */
.hero{
    max-width:1000px; margin:8px auto 0; padding:26px 22px;
    background:linear-gradient(135deg,#0A5573,#083d52); color:#fff; border-radius:18px;
    display:flex; gap:22px; align-items:center; flex-wrap:wrap;
    box-shadow:0 4px 20px rgba(10,85,115,.25);
}
.hero img{ width:120px; height:120px; border-radius:16px; background:#fff; padding:6px; flex:none; }
.hero h1{ margin:0 0 6px; font-size:26px; font-weight:800; }
.hero p{ margin:0 0 14px; color:#b8dde8; font-size:14px; max-width:560px; }
.hero .hero-by{ margin:-8px 0 14px; font-size:12.5px; }
.hero .hero-by a{ color:var(--accent-gold); text-decoration:none; }
.hero .hero-by a:hover{ text-decoration:underline; }
.hero .cta{ display:flex; gap:10px; flex-wrap:wrap; }
.hero .btn-primary{ background:var(--accent-gold); color:#111; }
.hero .btn-primary:hover{ background:#e09814; }
.hero .btn-ghost{ background:rgba(255,255,255,.12); color:#fff; backdrop-filter:blur(4px); }
.hero .hero-prog{ display:flex; align-items:center; gap:9px; margin:0 0 12px; font-size:12.5px; color:#cfeee9; }
.hero .hero-prog[hidden]{ display:none; }
.hero .hp-bar{ flex:0 0 120px; height:6px; border-radius:4px; background:rgba(255,255,255,.28); overflow:hidden; }
.hero .hp-bar > span{ display:block; height:100%; width:0; background:var(--accent-green); transition:width .3s; }
.hero .hp-txt{ font-weight:700; }

/* landing: quick links to interactive calculators */
.calc{ scroll-margin-top:70px; }  /* anchor target not hidden under fixed topbar */
.calcnav{ max-width:1000px; margin:24px auto 0; }
.calcnav h2{ display:flex; align-items:center; gap:8px; margin:0 0 12px; font-size:18px; font-weight:800; color:var(--chrome); }
.calcnav h2 .ic{ width:22px; height:22px; }
.calcgrid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:12px; }
.calcbtn{ display:flex; gap:11px; align-items:center; padding:12px 14px; border-radius:14px; background:#fff; color:#111; text-decoration:none; box-shadow:0 2px 10px rgba(0,0,0,.08); transition:box-shadow .15s, transform .15s; }
.calcbtn:hover{ box-shadow:0 5px 18px rgba(10,85,115,.18); transform:translateY(-1px); }
.calcbtn .cbi{ width:40px; height:40px; flex:none; border-radius:11px; background:var(--bg); color:var(--chrome); display:inline-flex; align-items:center; justify-content:center; }
.calcbtn .cbi .ic{ width:22px; height:22px; }
.calcbtn .cbt{ display:flex; flex-direction:column; min-width:0; }
.calcbtn .cbt b{ font-size:14px; }
.calcbtn .cbt small{ margin-top:2px; color:#5b6b6b; font-size:12.5px; }
.grid{ max-width:1000px; margin:18px auto 0; display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:13px; padding-bottom:50px; }
/* ---------- lessons section (landing) ---------- */
.lessons{ max-width:1000px; margin:26px auto 0; }
.sec-head{ display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; margin:0 0 12px; }
.lessons h2{ margin:0; font-size:20px; font-weight:800; color:var(--chrome); }
.sec-sub{ margin:0; font-size:13px; color:#5b6b6b; }
.lessons .grid{ margin-top:0; padding-bottom:0; }

.card{
    display:flex; gap:12px; align-items:flex-start; text-decoration:none; color:#111; background:#fff; border-radius:14px;
    padding:14px 16px; box-shadow:0 2px 10px rgba(0,0,0,.06); position:relative; transition:.14s;
    border-left:4px solid transparent;
}
.card:hover{ transform:translateY(-2px); box-shadow:0 8px 22px rgba(10,85,115,.14); }
.card .cico{
    flex:none; width:42px; height:42px; border-radius:12px; background:var(--bg); color:var(--chrome);
    display:inline-flex; align-items:center; justify-content:center;
}
.card .cico .ic{ width:22px; height:22px; }
.card .cbody{ display:flex; flex-direction:column; min-width:0; }
.card .cnum{ font-size:13px; color:#5b6b6b; font-weight:700; }
.card .ctitle{ font-size:15px; font-weight:700; margin:2px 0 0; line-height:1.35; }
.card .cdone{ position:absolute; top:12px; right:13px; color:var(--accent-green); font-weight:800; opacity:0; }
.card.done .cdone{ opacity:1; }
.card.done{ border-left-color:var(--accent-green); }

/* ---------- sidebar progress / site footer ---------- */
.site-foot{
    max-width:1000px; margin:30px auto 0; padding:20px 22px 26px; border-top:1px solid rgba(10,85,115,.15);
    display:flex; flex-wrap:wrap; gap:16px 28px; align-items:flex-start;
}
.site-foot .sf-brand{ display:flex; flex-direction:column; gap:3px; min-width:220px; }
.site-foot .sf-brand b{ font-size:14px; color:var(--chrome); }
.site-foot .sf-brand span{ font-size:12.5px; color:#5b6b6b; }
.site-foot .sf-links{ display:flex; flex-direction:column; gap:7px; }
.site-foot .sf-links a{ font-size:13px; color:var(--chrome); text-decoration:none; display:inline-flex; align-items:center; gap:6px; }
.site-foot .sf-links a:hover{ text-decoration:underline; }
.site-foot .sf-links .ic{ width:15px; height:15px; }
.site-foot .sf-note{ flex:1 1 100%; margin:0; font-size:12.5px; color:#4f5c5c; }

/* ---------- mobile sticky primary action ---------- */
.stickybar{
    display:none; position:fixed; left:0; right:0; bottom:0; z-index:78; gap:9px; padding:9px 12px;
    background:rgba(255,255,255,.96); box-shadow:0 -3px 14px rgba(0,0,0,.16); backdrop-filter:blur(6px);
}
.stickybar .btn{ flex:1; justify-content:center; min-height:46px; }
.stickybar .sb-icon{ flex:0 0 52px; }
.stickybar .btn-primary{ background:var(--chrome); color:#fff; }

/* demoted sheet titles on web (print keeps real H1 per sheet) */
.hd-alt{ margin:0; font-size:21px; font-weight:800; }

/* inline status icons replacing emoji from the chapter copy */
.emo{ width:1.05em; height:1.05em; display:inline-block; vertical-align:-.16em; }
.emo.e-ok{ color:#2f7d0f; }
.emo.e-warn{ color:#a8620a; }
.emo.e-no{ color:#c0392b; }
.emo.e-star{ color:#a8790b; }
.emo.e-hot{ color:#c85a1b; }

/* ---------- responsive ---------- */
@media (max-width:880px){
    #nav{ transform:translateX(-100%); transition:transform .25s ease; top:58px; }
    #nav.open{ transform:none; box-shadow:4px 0 22px rgba(0,0,0,.4); }
    main{ margin-left:0; }
    #menuBtn{ display:inline-flex; align-items:center; justify-content:center; }
    #backdrop.show{ display:block; position:fixed; inset:58px 0 0 0; background:rgba(0,0,0,.45); z-index:65; }
    #topbar .tb-brand small{ display:none; }
    #topbar .tb-home{ display:none; }  /* drawer nav already has หน้าแรก link */
    #search{ width:120px; }
    #nav a .lbl{ font-size:13px; }
    .stickybar{ display:flex; }
    body{ padding-bottom:68px; }
    article.chapter{ font-size:15px; line-height:1.65; }
    .qopt{ padding:12px 14px; }
    /* touch targets: secondary links must still be tappable with a thumb */
    .site-foot .sf-links a{ min-height:40px; align-items:center; padding:8px 0; }
    .site-foot .sf-brand b{ font-size:14.5px; }
    .hero .hero-by a{ display:inline-block; min-height:40px; padding:10px 0; }
    #topbar .tb-brand{ padding:11px 0; }
    #search{ height:40px; }
}
@media (max-width:520px){
    #topbar .tb-brand{ font-size:13px; }
    #search{ width:92px; }
}

/* ---------- make the A4 sheet fluid on small screens (screen only) ---------- */
@media screen and (max-width:840px){
    .sheet{ width:auto; min-height:0; margin:10px 0; padding:16px 14px; }
    .pn, .donebar, .quiz, .hero, .grid{ max-width:none; }
    .pn{ flex-direction:column; }
}
@media screen and (max-width:560px){
    .cols, .cols.cols3, .res, .res.res3{ grid-template-columns:1fr; }
    .hd-main h1{ font-size:18px; }
    .sheet{ padding:13px 11px; }
    table{ font-size:12.5px; }
    th, td{ padding:4px 6px; }
}

/* ---------- print: hide all chrome, show only the chapter sheets ---------- */
@media print{
    #topbar, #progbar, #nav, #backdrop, .pn, .donebar, .quiz, .print-ws, #results, .stickybar, .site-foot{ display:none !important; }
    main{ margin:0; padding:0; background:#fff; }
    .wrap{ max-width:none; margin:0; padding:0; }
    input.ix, textarea.ix{ background:transparent; border-bottom:1.4px solid #000; color:#000; }
    .term{ border-bottom:none; }
    .term .tip-pop{ display:none !important; }
}

