/* /masahef/ — V15
   Scoped styles for the Masahef section.
   Important: header/footer/main.js remain central and untouched. */

:root{
  --mh-gold:#b28a2f;
  --mh-gold-2:#d7bd73;
  --mh-ink:#1c2422;
  --mh-muted:#68716e;
  --mh-line:rgba(36,49,45,.14);
  --mh-surface:#fff;
  --mh-soft:#f7f5ef;
  --mh-green:#244c3c;
  --mh-shadow:0 14px 38px rgba(31,41,37,.08);
  --mh-radius:20px;
}

html[data-theme="dark"]{
  --mh-ink:#f1f3ef;
  --mh-muted:#aeb7b2;
  --mh-line:rgba(255,255,255,.13);
  --mh-surface:#151b19;
  --mh-soft:#101513;
  --mh-green:#b8d2c7;
  --mh-shadow:0 14px 38px rgba(0,0,0,.24);
}

/* Prevent the section CSS from fighting the central V15 layout. */
.mh-body{background:var(--mh-soft);color:var(--mh-ink)}
.mh-body :where(.mh-page,.mh-reader-main),
.mh-body :where(.mh-page,.mh-reader-main) *,
.mh-body :where(.mh-page,.mh-reader-main) *::before,
.mh-body :where(.mh-page,.mh-reader-main) *::after{box-sizing:border-box}

/* Critical fix: author display rules (.mh-btn, .mh-resume, toolbar, status...)
   must never override the native hidden attribute. */
.mh-body [hidden]{display:none!important}

.mh-page{min-height:60vh;padding:0 0 54px;overflow-x:clip}
.mh-wrap{width:min(1180px,calc(100% - 28px));margin-inline:auto}
.mh-sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Hero */
.mh-hero{
  padding:clamp(24px,4.5vw,56px) 0 30px;
  background:
    radial-gradient(circle at 85% 20%,rgba(178,138,47,.13),transparent 34%),
    linear-gradient(180deg,var(--mh-surface),var(--mh-soft));
  border-bottom:1px solid var(--mh-line)
}
.mh-hero-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(300px,.8fr);gap:clamp(24px,4vw,50px);align-items:center}
.mh-breadcrumb{display:flex;gap:8px;align-items:center;flex-wrap:wrap;font-size:.88rem;color:var(--mh-muted);margin:0 0 18px;padding:0}
.mh-breadcrumb a{color:inherit;text-decoration:none}
.mh-breadcrumb a:hover{text-decoration:underline}
.mh-eyebrow{display:inline-flex;align-items:center;gap:7px;font-size:.82rem;font-weight:800;color:#7c6226;background:rgba(215,189,115,.19);border:1px solid rgba(178,138,47,.25);padding:6px 10px;border-radius:999px}
html[data-theme="dark"] .mh-eyebrow{color:#e8d399}
.mh-hero h1,.mh-detail-copy h1{font-size:clamp(2rem,4.4vw,3.65rem);line-height:1.28;margin:13px 0 12px;letter-spacing:0}
.mh-hero-copy>p,.mh-lead{font-size:clamp(1rem,1.5vw,1.18rem);line-height:1.95;color:var(--mh-muted);max-width:760px;margin:0}
.mh-hero-actions,.mh-detail-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:20px}

/* Buttons */
.mh-btn{
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border-radius:13px;
  padding:10px 16px;
  border:1px solid var(--mh-line);
  font:inherit;
  line-height:1.35;
  font-weight:800;
  text-decoration:none;
  cursor:pointer;
  transition:transform .16s ease,border-color .16s ease,background .16s ease,box-shadow .16s ease;
  color:var(--mh-ink);
  background:var(--mh-surface)
}
.mh-btn:hover{transform:translateY(-1px);border-color:rgba(178,138,47,.52)}
.mh-btn-primary{background:linear-gradient(135deg,#273d35,#355c4b);color:#fff;border-color:transparent;box-shadow:0 8px 22px rgba(36,76,60,.16)}
html[data-theme="dark"] .mh-btn-primary{background:linear-gradient(135deg,#d2b86e,#b99138);color:#171a18}
.mh-btn-download{background:linear-gradient(135deg,#c49b3a,#a47c21);color:#fff;border-color:transparent}
.mh-btn-soft{background:var(--mh-surface)}

/* Featured */
.mh-featured{display:grid;grid-template-columns:150px minmax(0,1fr);align-items:center;gap:18px;padding:18px;border-radius:24px;background:var(--mh-surface);border:1px solid var(--mh-line);box-shadow:var(--mh-shadow)}
.mh-featured-cover{max-width:150px;width:100%}
.mh-featured h2{font-size:1.28rem;line-height:1.55;margin:8px 0 4px}
.mh-featured p{margin:0 0 10px;color:var(--mh-muted);line-height:1.7}
.mh-badge{font-size:.76rem;font-weight:900;color:#7a5b16}
.mh-featured-state{display:flex;gap:8px;align-items:center;flex-wrap:wrap;color:var(--mh-muted);font-size:.84rem;margin:8px 0 12px}
.mh-file-state.is-ready{color:#2f7456;font-weight:800}
.mh-file-state.is-missing{color:#916f21;font-weight:800}
html[data-theme="dark"] .mh-file-state.is-ready{color:#8fd0af}

/* Covers */
.mh-book-cover{aspect-ratio:420/610;border-radius:17px;overflow:hidden;background:#19382e;box-shadow:0 13px 30px rgba(21,35,30,.15);position:relative}
.mh-book-cover img{width:100%;height:100%;display:block;object-fit:cover}
.mh-cover-placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:22px;border:1px solid rgba(255,255,255,.18);color:#f7e4a7;background:linear-gradient(145deg,#24493b,#132a22)}
.mh-cover-placeholder::before,.mh-cover-placeholder::after{content:"";position:absolute;inset:14px;border:1px solid rgba(229,196,106,.55);border-radius:12px;pointer-events:none}
.mh-cover-placeholder::after{inset:22px;border-style:double}
.mh-cover-placeholder b{max-width:82%;font-size:clamp(.95rem,1.5vw,1.25rem);line-height:1.7;z-index:1}
.mh-cover-placeholder small{z-index:1;margin-top:9px;color:#d6c79e}
.mh-cover-mark{font-size:1.9rem;margin-bottom:12px;z-index:1}
.mh-tone-1{background:linear-gradient(145deg,#24493b,#132a22)}
.mh-tone-2{background:linear-gradient(145deg,#233b55,#162638)}
.mh-tone-3{background:linear-gradient(145deg,#54452a,#292116)}
.mh-tone-4{background:linear-gradient(145deg,#53363b,#2d1c20)}
.mh-tone-5{background:linear-gradient(145deg,#39423b,#1c211d)}

/* Resume */
.mh-resume{margin-top:16px;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;align-items:center;padding:12px 14px;border:1px solid rgba(178,138,47,.33);border-radius:14px;background:rgba(215,189,115,.09);color:var(--mh-ink);text-decoration:none}
.mh-resume span,.mh-resume small{color:var(--mh-muted)}
.mh-resume b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Library */
.mh-section{padding:clamp(36px,5vw,64px) 0}
.mh-section-head{display:flex;align-items:end;justify-content:space-between;gap:18px;margin-bottom:18px}
.mh-section-head h2{font-size:clamp(1.5rem,2.8vw,2.2rem);line-height:1.35;margin:8px 0 5px}
.mh-section-head p{color:var(--mh-muted);margin:0;line-height:1.8}
.mh-toolbar{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;padding:12px;border:1px solid var(--mh-line);border-radius:17px;background:var(--mh-surface);position:relative;z-index:2;box-shadow:0 7px 22px rgba(25,35,31,.045)}
.mh-search{min-width:min(100%,320px);flex:1;position:relative;display:block}
.mh-search input{width:100%;height:46px;border:1px solid var(--mh-line);border-radius:13px;background:var(--mh-soft);color:var(--mh-ink);padding:0 15px 0 44px;font:inherit;outline:none}
.mh-search input:focus{border-color:rgba(178,138,47,.65);box-shadow:0 0 0 3px rgba(178,138,47,.11)}
.mh-search>span:not(.mh-sr-only){position:absolute;left:15px;top:50%;transform:translateY(-50%);font-size:1.25rem;color:var(--mh-muted);pointer-events:none}
.mh-filters{display:flex;gap:7px;flex-wrap:wrap}
.mh-filters button{border:1px solid var(--mh-line);background:var(--mh-soft);color:var(--mh-ink);border-radius:999px;padding:8px 12px;font:inherit;font-weight:700;cursor:pointer;white-space:nowrap}
.mh-filters button.is-active{background:#2d4d41;color:#fff;border-color:#2d4d41}
html[data-theme="dark"] .mh-filters button.is-active{background:#c5a653;color:#181b19;border-color:#c5a653}
.mh-results{font-size:.86rem;color:var(--mh-muted);margin:12px 4px}
.mh-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.mh-card{background:var(--mh-surface);border:1px solid var(--mh-line);border-radius:var(--mh-radius);padding:11px;box-shadow:0 9px 24px rgba(30,40,36,.05);display:flex;flex-direction:column;min-width:0;overflow:hidden}
.mh-card-cover{display:block;text-decoration:none}
.mh-card-body{display:flex;flex-direction:column;flex:1;min-width:0;padding:11px 3px 2px}
.mh-card-meta{display:flex;justify-content:space-between;align-items:center;gap:7px;flex-wrap:wrap;color:var(--mh-muted);font-size:.74rem}
.mh-card h2{font-size:1.05rem;line-height:1.55;margin:8px 0 5px}
.mh-card h2 a{color:var(--mh-ink);text-decoration:none}
.mh-card p{color:var(--mh-muted);line-height:1.7;margin:0 0 13px;font-size:.89rem}
.mh-card-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:auto}
.mh-card-actions .mh-btn{min-height:39px;padding:8px 10px;font-size:.82rem;flex:1 1 110px}
.mh-empty{padding:28px;text-align:center;border:1px dashed var(--mh-line);border-radius:17px;background:var(--mh-surface)}
.mh-empty span{display:block;color:var(--mh-muted);margin-top:5px}

/* Linked tools / SEO */
.mh-link-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.mh-link-grid a,.mh-mini-grid a{display:flex;flex-direction:column;gap:6px;padding:17px;border:1px solid var(--mh-line);border-radius:15px;background:var(--mh-surface);color:var(--mh-ink);text-decoration:none;transition:transform .16s ease,border-color .16s ease}
.mh-link-grid a:hover,.mh-mini-grid a:hover{transform:translateY(-2px);border-color:rgba(178,138,47,.48)}
.mh-link-grid span,.mh-mini-grid span{color:var(--mh-muted);font-size:.88rem;line-height:1.65}
.mh-seo{background:var(--mh-surface);border-top:1px solid var(--mh-line);border-bottom:1px solid var(--mh-line)}
.mh-prose{max-width:920px;line-height:2}
.mh-prose h2{font-size:clamp(1.4rem,2.5vw,2rem);line-height:1.45;margin:0 0 12px}
.mh-prose h3{font-size:1.2rem;line-height:1.5;margin:26px 0 8px}
.mh-prose p{color:var(--mh-muted);margin:0 0 13px}
.mh-faq{display:grid;gap:9px;margin-top:20px}
.mh-faq details{border:1px solid var(--mh-line);border-radius:14px;background:var(--mh-soft);padding:13px 16px}
.mh-faq summary{font-weight:800;cursor:pointer}
.mh-faq details p{margin:10px 0 0}

/* Detail page */
.mh-detail-hero{padding:clamp(24px,4.5vw,52px) 0;background:linear-gradient(180deg,var(--mh-surface),var(--mh-soft));border-bottom:1px solid var(--mh-line)}
.mh-detail-grid{display:grid;grid-template-columns:minmax(210px,300px) minmax(0,1fr);gap:clamp(24px,4vw,50px);align-items:center}
.mh-detail-cover{max-width:300px;width:100%}
.mh-status-box{margin-top:18px;display:flex;gap:9px;align-items:center;flex-wrap:wrap;color:var(--mh-muted);font-size:.9rem}
.mh-status-dot{width:9px;height:9px;border-radius:50%;background:#b28a2f;box-shadow:0 0 0 5px rgba(178,138,47,.11);flex:0 0 auto}
.mh-specs{display:flex;gap:9px;flex-wrap:wrap;margin:20px 0 0;padding:0}
.mh-specs div{min-width:116px;padding:10px 12px;border-radius:13px;background:var(--mh-surface);border:1px solid var(--mh-line)}
.mh-specs dt{font-size:.75rem;color:var(--mh-muted)}
.mh-specs dd{margin:2px 0 0;font-weight:800}
.mh-detail-prose{background:var(--mh-surface);border:1px solid var(--mh-line);border-radius:19px;padding:clamp(20px,4vw,36px)}
.mh-note{margin-top:22px;padding:15px;border-inline-start:4px solid var(--mh-gold);background:rgba(178,138,47,.08);border-radius:12px}
.mh-note p{margin:5px 0 0}
.mh-mini-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.mh-resume-detail{max-width:620px}

/* Reader */
.mh-reader-main{min-height:70vh;background:var(--mh-soft);padding:18px 0 34px}
.mh-reader-top{margin-bottom:12px}
.mh-reader-heading{display:flex;align-items:end;justify-content:space-between;gap:14px}
.mh-reader-heading h1{font-size:clamp(1.4rem,2.7vw,2.15rem);line-height:1.4;margin:7px 0 0}
.mh-reader-shell{width:min(1380px,calc(100% - 20px));margin-inline:auto;background:var(--mh-surface);border:1px solid var(--mh-line);border-radius:17px;overflow:hidden;box-shadow:var(--mh-shadow)}
.mh-reader-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;padding:10px;border-bottom:1px solid var(--mh-line);background:var(--mh-surface)}
.mh-page-nav,.mh-reader-actions{display:flex;gap:7px;align-items:center;flex-wrap:wrap}
.mh-page-nav button,.mh-reader-actions a,.mh-reader-actions button{min-height:38px;border:1px solid var(--mh-line);border-radius:10px;background:var(--mh-soft);color:var(--mh-ink);font:inherit;font-weight:700;padding:7px 11px;text-decoration:none;cursor:pointer;line-height:1.25}
.mh-page-nav label{display:flex;align-items:center;gap:7px;font-size:.85rem;color:var(--mh-muted)}
.mh-page-nav input{width:72px;height:38px;border:1px solid var(--mh-line);border-radius:10px;background:var(--mh-soft);color:var(--mh-ink);text-align:center;font:inherit}

/* The check message is deliberately compact. It disappears completely once hidden. */
.mh-reader-status{min-height:96px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:5px;padding:18px 20px;color:var(--mh-muted);background:var(--mh-surface)}
.mh-reader-status::before{content:"";width:22px;height:22px;border:2px solid rgba(178,138,47,.25);border-top-color:var(--mh-gold);border-radius:50%;animation:mh-spin .8s linear infinite;margin-bottom:2px}
.mh-reader-status b{color:var(--mh-ink);font-size:1rem;line-height:1.5}
.mh-reader-status span{font-size:.84rem;line-height:1.6}
@keyframes mh-spin{to{transform:rotate(360deg)}}

.mh-reader-frame-wrap{background:#343937;min-height:0}
.mh-reader-frame{display:block;border:0;width:100%;height:min(82vh,940px);min-height:560px;background:#343937}
.mh-reader-shell:fullscreen{width:100%;height:100%;border:0;border-radius:0;background:#343937}
.mh-reader-shell:fullscreen .mh-reader-frame{height:calc(100dvh - 60px);min-height:0}

/* Only section controls get the focus treatment — not the central header/footer. */
.mh-body :where(.mh-page,.mh-reader-main) :focus-visible{outline:3px solid rgba(178,138,47,.65);outline-offset:3px}

@media(max-width:980px){
  .mh-hero-grid{grid-template-columns:1fr}
  .mh-featured{max-width:650px}
  .mh-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .mh-detail-grid{grid-template-columns:220px minmax(0,1fr)}
  .mh-link-grid,.mh-mini-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media(max-width:720px){
  .mh-wrap{width:min(100% - 20px,1180px)}
  .mh-hero{padding-top:20px}
  .mh-hero h1,.mh-detail-copy h1{font-size:clamp(1.75rem,8.5vw,2.7rem)}
  .mh-featured{grid-template-columns:102px minmax(0,1fr);padding:12px;border-radius:17px}
  .mh-featured-cover{max-width:102px}
  .mh-featured h2{font-size:1.05rem}
  .mh-featured p{font-size:.86rem}
  .mh-toolbar{padding:10px}
  .mh-filters{width:100%;overflow-x:auto;overscroll-behavior-inline:contain;flex-wrap:nowrap;padding-bottom:2px;scrollbar-width:none}
  .mh-filters::-webkit-scrollbar{display:none}
  .mh-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .mh-card{padding:9px;border-radius:15px}
  .mh-card-body{padding:9px 2px 1px}
  .mh-card h2{font-size:.94rem}
  .mh-card p{font-size:.8rem}
  .mh-card-meta{font-size:.66rem}
  .mh-card-actions{display:grid;grid-template-columns:1fr}
  .mh-link-grid,.mh-mini-grid{grid-template-columns:1fr}
  .mh-detail-grid{grid-template-columns:1fr}
  .mh-detail-cover{width:min(238px,68vw);margin-inline:auto}
  .mh-detail-actions .mh-btn{flex:1 1 46%}
  .mh-reader-main{padding-top:14px}
  .mh-reader-heading{align-items:flex-start;flex-direction:column}
  .mh-reader-shell{width:calc(100% - 12px);border-radius:13px}
  .mh-reader-toolbar{align-items:stretch;padding:8px}
  .mh-page-nav,.mh-reader-actions{width:100%}
  .mh-page-nav{display:grid;grid-template-columns:auto minmax(0,1fr) auto}
  .mh-page-nav label{justify-content:center;min-width:0}
  .mh-page-nav label input{max-width:68px}
  .mh-page-nav>span{display:none}
  .mh-reader-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  .mh-reader-actions>*{display:flex;align-items:center;justify-content:center;text-align:center;min-width:0}
  .mh-reader-status{min-height:82px;padding:14px 12px}
  .mh-reader-frame{height:76dvh;min-height:500px}
}

@media(max-width:430px){
  .mh-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .mh-card{padding:7px}
  .mh-book-cover{border-radius:14px}
  .mh-card h2{font-size:.88rem}
  .mh-card p{font-size:.76rem;line-height:1.6}
  .mh-card-actions .mh-btn{font-size:.77rem;padding:7px 8px}
  .mh-featured{grid-template-columns:88px minmax(0,1fr);gap:11px}
  .mh-featured-cover{max-width:88px}
  .mh-featured .mh-btn{font-size:.78rem;padding:8px 9px}
  .mh-detail-actions .mh-btn{flex-basis:100%}
  .mh-reader-actions{grid-template-columns:1fr 1fr}
  .mh-page-nav button{padding-inline:8px}
  .mh-page-nav label{font-size:.77rem}
  .mh-reader-frame{height:72dvh;min-height:460px}
}

@media(prefers-reduced-motion:reduce){
  .mh-body :where(.mh-page,.mh-reader-main) *,
  .mh-body :where(.mh-page,.mh-reader-main) *::before,
  .mh-body :where(.mh-page,.mh-reader-main) *::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}
}
