/* Mobile overlay for bhaktiswarupadamodara.com.
   Loaded after the legacy styles by the edge layer; never edit legacy files.
   !important is only used where the legacy markup has inline styles or HTML attributes. */

:root {
  --gold: #ffcc00;
  --gold-soft: #e9c46a;
  --maroon: #5a0f14;
  --paper: #fff6ed;
  --ink: #2b2118;
  --tap: 48px;
}

/* ---------- Everywhere, small screens ---------- */
@media (max-width: 1000px) {
  html { -webkit-text-size-adjust: 100%; }
  img, video, iframe, object, embed { max-width: 100% !important; height: auto; }
  body { overflow-wrap: break-word; }
}

/* ---------- Home page (990px table) ---------- */
@media (max-width: 1000px) {
  body[data-tpl="home"] { padding: 0 !important; background-size: 300px; }
  body[data-tpl="home"] center > div { padding: 12px; }
  body[data-tpl="home"] table,
  body[data-tpl="home"] tbody,
  body[data-tpl="home"] tr,
  body[data-tpl="home"] td {
    display: block;
    width: auto !important;
    max-width: 100%;
    box-sizing: border-box;
  }
  body[data-tpl="home"] center > div > table {
    border: 1px solid var(--gold) !important;
    border-radius: 6px;
    overflow: hidden;
  }

  /* Header: title flanked by the flower GIFs, kept on one row */
  body[data-tpl="home"] td[colspan] tr {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
  }
  body[data-tpl="home"] td[colspan] td { padding: 0; }
  body[data-tpl="home"] td[colspan] img { width: 44px !important; }
  body[data-tpl="home"] h1 { font-size: clamp(1.25rem, 5.5vw, 1.9rem); line-height: 1.25; margin: 0; }

  /* Portrait */
  body[data-tpl="home"] center > div > table > tbody > tr:nth-child(2) > td:first-child { padding: 0; }
  body[data-tpl="home"] img[src*="BSDS-guru"] {
    display: block;
    width: 100% !important;
    max-height: 62vh;
    object-fit: cover;
    object-position: 50% 20%;
  }

  /* Menu column: <br>-separated links become tap-sized rows */
  body[data-tpl="home"] center > div > table > tbody > tr:nth-child(2) > td:nth-child(2) {
    padding: 8px 0 !important;
    text-align: left;
    background: rgba(0, 0, 0, .25);
  }
  body[data-tpl="home"] center > div > table > tbody > tr:nth-child(2) > td:nth-child(2) br { display: none; }
  body[data-tpl="home"] center > div > table > tbody > tr:nth-child(2) > td:nth-child(2) a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--tap);
    padding: 0 20px;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 204, 0, .25);
  }
  body[data-tpl="home"] center > div > table > tbody > tr:nth-child(2) > td:nth-child(2) a::after {
    content: "\203A";
    font-size: 1.4rem;
    opacity: .7;
  }
  body[data-tpl="home"] center > div > table > tbody > tr:nth-child(2) > td:nth-child(2) a:last-child { border-bottom: 0; }
  /* Gap between the book chapters and the media links */
  body[data-tpl="home"] a[href="slides/"] { margin-top: 12px; border-top: 1px solid rgba(255, 204, 0, .25); }

  /* Book panel */
  body[data-tpl="home"] td[style*="bookcov"] {
    padding: 28px 20px 32px;
    background-size: cover !important;
    line-height: 1.6;
  }
  body[data-tpl="home"] td[style*="bookcov"] h3 { font-size: 1.1rem; margin: 12px 0; }
  body[data-tpl="home"] td[style*="bookcov"] a {
    display: inline-block;
    min-height: 40px;
    line-height: 40px;
    padding: 0 6px;
  }
}

/* ---------- Bhagavata Sevarpanam story pages ---------- */
@media (max-width: 760px) {
  body[data-tpl="sevarpanam"],
  body[data-tpl="videos"] {
    min-width: 0;
    padding: 0 16px 88px;
    color: var(--ink);
  }

  /* Top bar: series name + chapter, with the arrow buttons moved to the bottom bar */
  body[data-tpl="sevarpanam"] .nav_container {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 14px 0 10px;
    font-size: .8rem;
    letter-spacing: .04em;
    border-bottom: 1px solid #d9c4a8;
  }
  body[data-tpl="sevarpanam"] .nav_container > div { width: auto; float: none; min-width: 0; }
  body[data-tpl="sevarpanam"] .nav_container > div > div { float: none !important; }
  body[data-tpl="sevarpanam"] .nav_container hr,
  body[data-tpl="sevarpanam"] .nav_middle { display: none; }
  body[data-tpl="sevarpanam"] .nav_right { text-align: right; }

  /* Multi-column magazine layout -> single column in reading order */
  body[data-tpl="sevarpanam"] .content_container div:not([class*="nav_"]) {
    float: none !important;
    width: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  /* Inline inch-based side padding/margins from the desktop layout */
  body[data-tpl="sevarpanam"] .content_container [style*="padding"] { padding-left: 0 !important; padding-right: 0 !important; }
  body[data-tpl="sevarpanam"] .content_container [style*="margin-left"],
  body[data-tpl="sevarpanam"] .content_container [style*="margin-right"] { margin-left: 0 !important; margin-right: 0 !important; }

  /* Narrow side columns (pull quotes, captions) follow the main story text */
  body[data-tpl="sevarpanam"] .content_container { display: flex; flex-direction: column; }
  body[data-tpl="sevarpanam"] .content_container > .mr200,
  body[data-tpl="sevarpanam"] .content_container > .ml200 { order: 2; }
  body[data-tpl="sevarpanam"] .content_container > [class$="200"] > * { padding-top: 0 !important; }
  body[data-tpl="sevarpanam"] .title {
    margin: 20px 0 8px !important;
    font-size: 1.6rem;
    line-height: 1.25;
    text-align: center;
  }

  /* Readable body text */
  body[data-tpl="sevarpanam"] p {
    font-size: 1.075rem;
    line-height: 1.6 !important;
    text-align: left;
    text-indent: 1.25em;
  }
  body[data-tpl="sevarpanam"] p.top,
  body[data-tpl="sevarpanam"] p.no_indent,
  body[data-tpl="sevarpanam"] p.drop_cap,
  body[data-tpl="sevarpanam"] p.caption { text-indent: 0; }
  body[data-tpl="sevarpanam"] p.caption { font-size: .85rem; line-height: 1.4 !important; color: #6b5a48; }
  body[data-tpl="sevarpanam"] .sp { margin-left: 0; margin-right: 0; }
  body[data-tpl="sevarpanam"] p.drop_cap span img { width: 34px !important; height: auto !important; }

  /* Images: full width, a little breathing room */
  body[data-tpl="sevarpanam"] img.collapse { margin: 12px 0 4px; border-radius: 3px; }
  body[data-tpl="sevarpanam"] img.portrait_l,
  body[data-tpl="sevarpanam"] img.portrait_r { float: none; display: block; margin: 12px auto; padding: 0; }

  /* Pull quotes from the side columns: drop the desktop offsets, style as blockquotes */
  body[data-tpl="sevarpanam"] [class^="quote_"],
  body[data-tpl="sevarpanam"] .traits,
  body[data-tpl="sevarpanam"] .traits_trans {
    padding: 0 !important;
    margin-top: 24px !important;
    text-indent: 0;
    font-size: 1.2rem;
  }
  body[data-tpl="sevarpanam"] [class^="quote_"] {
    padding: 16px 18px 0 !important;
    border-left: 3px solid currentColor;
    text-align: left;
  }
  body[data-tpl="sevarpanam"] [class^="attrib_"] {
    padding: 4px 18px 16px;
    margin: 0 0 24px;
    border-left: 3px solid currentColor;
    text-align: left;
    text-indent: 0;
    font-size: 1rem;
  }

  /* Tables inside stories scroll sideways instead of breaking the page */
  body[data-tpl="sevarpanam"] table { display: block; max-width: 100%; overflow-x: auto; }

  /* Bottom bar: big prev / contents / next buttons, fixed to the screen */
  body[data-tpl="sevarpanam"] .nav_bottom,
  body[data-tpl="sevarpanam"] .nav_bottom_l,
  body[data-tpl="sevarpanam"] .nav_bottom_r {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    width: auto;
    margin: 0 !important;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--paper);
    border-top: 1px solid #d9c4a8;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
    float: none;
  }
  body[data-tpl="sevarpanam"] .nav_bottom a,
  body[data-tpl="sevarpanam"] .nav_bottom_l a,
  body[data-tpl="sevarpanam"] .nav_bottom_r a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap);
    min-height: var(--tap);
  }
  body[data-tpl="sevarpanam"] .nav_bottom img,
  body[data-tpl="sevarpanam"] .nav_bottom_l img,
  body[data-tpl="sevarpanam"] .nav_bottom_r img { padding: 0; margin: 0; }
  body[data-tpl="sevarpanam"] .nav_left_btn,
  body[data-tpl="sevarpanam"] .nav_right_btn { width: 22px; }
  body[data-tpl="sevarpanam"] .nav_mid_btn { width: 32px; }
  body[data-tpl="sevarpanam"] .cartouche { display: none; }

  /* Video page: same top bar as the stories, player and blurb stacked */
  body[data-tpl="videos"] .nav_container {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0 10px;
    font-size: .8rem;
    border-bottom: 1px solid #d9c4a8;
  }
  body[data-tpl="videos"] .nav_container > div { width: auto; float: none; min-width: 0; }
  body[data-tpl="videos"] .nav_container > div > div { float: none !important; }
  body[data-tpl="videos"] .nav_container hr,
  body[data-tpl="videos"] .nav_middle { display: none; }
  body[data-tpl="videos"] [style*="margin-left"] { margin-left: 0 !important; }
  body[data-tpl="videos"] .content_container > div { float: none !important; width: auto !important; }
  body[data-tpl="videos"] .shadow { float: none !important; margin: 12px 0 !important; }
  body[data-tpl="videos"] #mahaPlayer { width: 100% !important; }
}

/* ---------- Newsletter (contact) and slides: fixed-width tables ---------- */
@media (max-width: 820px) {
  body[data-tpl="newsletter"] table,
  body[data-tpl="newsletter"] .tbMain,
  body[data-tpl="newsletter"] .tbBody { width: 100% !important; max-width: 100%; }
  body[data-tpl="newsletter"] td { display: block; width: auto !important; height: auto !important; }
  body[data-tpl="newsletter"] img[src*="space.gif"] { display: none; }
  body[data-tpl="slides"] table { width: 100% !important; }
  body[data-tpl="slides"] td { display: block; width: auto !important; }
}

/* ---------- Sadhu-sanga (WordPress theme from mahaprabhu.net) ---------- */
@media (max-width: 800px) {
  body[data-tpl="satsanga"] #container,
  body[data-tpl="satsanga"] #acharyabox,
  body[data-tpl="satsanga"] #left-col,
  body[data-tpl="satsanga"] #mainmain,
  body[data-tpl="satsanga"] #main,
  body[data-tpl="satsanga"] #content,
  body[data-tpl="satsanga"] #sidemenu,
  body[data-tpl="satsanga"] #footer {
    width: auto !important;
    float: none !important;
    left: 0 !important;
    margin-left: 0 !important;
    box-sizing: border-box;
  }
  body[data-tpl="satsanga"] #container { padding-left: 34px; min-width: 0 !important; }
  body[data-tpl="satsanga"] #nav { white-space: normal; }
  body[data-tpl="satsanga"] #topleft { width: 30px; background-size: contain; }
  body[data-tpl="satsanga"] #banner { left: 34px; right: 0; width: auto; background-size: contain; background-repeat: no-repeat; }
  body[data-tpl="satsanga"] #acharyabox [id^="sg"] { display: none; }
  body[data-tpl="satsanga"] #main { background: none; padding: 0 12px; }
  body[data-tpl="satsanga"] #left-col { padding-left: 12px !important; }
  body[data-tpl="satsanga"] #nav { position: static !important; float: none !important; width: auto !important; margin: 12px 0 0 !important; }
  body[data-tpl="satsanga"] #nav ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
  body[data-tpl="satsanga"] #nav li { float: none !important; width: auto !important; height: auto !important; margin: 0 !important; background: none !important; }
  body[data-tpl="satsanga"] #nav a {
    display: block;
    width: auto !important;
    height: auto !important;
    padding: 10px 12px !important;
    background: #ece8fb !important;
    border: 1px solid #b9b0e6;
    border-radius: 4px;
    line-height: 1.2;
  }
  body[data-tpl="satsanga"] #content p { text-align: left !important; }
  body[data-tpl="satsanga"] .dbx-tooltip { display: none !important; }
}
