﻿/* ==========================================================================
   s3waas-mobile.css  -  mobile fixes for MasterPage.master pages + index.aspx
   LOAD LAST: after dbim-v3.css (MasterPage.master line ~325), before print.css.
   ========================================================================== */

/* ---- 1. Main menu toggle --------------------------------------------------
   Home page (.topnav): master's s3waas-gigw.css hides .nav-toggle with !important,
   which left phones with no menu. Re-show it below 992px (higher specificity). */
@media (max-width: 991px) {
  .topnav .nav-toggle { display: block !important; min-height: 44px; min-width: 44px; }
}
@media (min-width: 992px) {
  .topnav .nav-toggle, .s3-nav-toggle { display: none !important; }
}

/* Inner pages (.s3-nav): new toggle button, see ctd-mobile-nav.js */
.s3-nav-toggle {
  display: none; align-items: center; gap: .5rem; margin: .4rem .75rem .4rem auto;
  min-height: 44px; padding: .4rem .9rem; font: inherit; font-weight: 600; color: #fff;
  background: transparent; border: 2px solid #fff; border-radius: 6px; cursor: pointer;
}
.s3-nav-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

@media (max-width: 991px) {
  .s3-nav-toggle { display: flex; }
  .s3-nav .nav-list:not(.open) { display: none !important; }
  .s3-nav .nav-list.open {
    display: flex !important; flex-direction: column !important; flex-wrap: nowrap !important;
    align-items: stretch !important; justify-content: flex-start !important;
    max-height: calc(100dvh - 8rem); overflow-y: auto; border-top: 1px solid rgba(255,255,255,.25);
  }
  .s3-nav .nav-list.open li { width: 100%; height: auto !important; }
  .s3-nav .nav-list.open a {
    width: 100%; min-height: 44px; padding: .8rem 1rem !important; white-space: normal !important;
    border-bottom: 1px solid rgba(255,255,255,.15) !important;
  }
}

/* ---- 2. Replacement for the "Mobile Viewport Guard" in MasterPage.master ----
   Delete that whole @media (max-width:480px) block from the master and use these
   targeted rules instead (no  * {max-width:100% !important}, no table display:block). */
@media (max-width: 480px) {
  .s3-container, .wrap { width: calc(100% - 1.5rem); }
}
img, video, iframe, svg { max-width: 100%; }
img, video { height: auto; }
.s3-main, main { min-width: 0; }
.s3-main p, .s3-main li, .s3-main a { overflow-wrap: break-word; }   /* break-word (not anywhere): never shrinks table columns to 1 letter */
.table-wrap, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.s3-dialog { width: min(48rem, calc(100% - 1rem)); }

/* ---- 3. Top bar at 320-480px ---------------------------------------------- */
@media (max-width: 480px) {
  .s3-topbar .topbar-inner { flex-wrap: wrap; }
  .s3-topbar .topbar-gov { flex: 1 1 100%; order: 0; justify-content: center; text-align: center; flex-wrap: wrap; font-size: .8rem; }
  .s3-topbar .topbar-links { order: 1; }
  .s3-topbar .topbar-tools { order: 2; margin-left: auto; }
  .tb-menu { right: 0; max-width: calc(100vw - 1rem); }
  .tb-menu--a11y { min-width: 0; width: min(18rem, calc(100vw - 1rem)); }
}

/* ---- 4. Header, search, pager, buttons: touch size ---------------------- */
@media (max-width: 768px) {
  .header-inner { justify-content: center; text-align: center; }
  .header-end { width: 100%; align-items: stretch; }
  .hdr-search { max-width: none; }
  .hdr-search input[type=search], .hdr-search button { min-height: 44px; }
  .pr-btn, .pr-page, .pr-field, .pr-btn--sm { min-height: 44px; }
  .pr-field--search { width: 100%; flex: 1 1 auto; }
  .pr-search { width: 100%; }
  .pr-row { justify-content: stretch; }
  .tile-link { padding: 1rem; }
  .dash-card { width: 100%; }
  .dash__art img { max-height: 12rem; }
  .s3-footer .f-top { width: 2.75rem; height: 2.75rem; }
}
@media (max-width: 480px) {
  .s3-table, .s3-table--press, .s3-table--archive { min-width: 32rem; }   /* scrolls inside .table-wrap */
}

/* ---- 5. Top bar icons (Skip to main | Language | Accessibility): one size larger on laptop / desktop only ---- */
/* Phones and tablets (below 992px) keep the original 24px icons. */
@media (min-width: 992px) {
  .s3-topbar .top-bar-icon-btn svg,
  .s3-topbar .tb-btn svg,
  .s3-topbar a.skip-main svg {
    width: 32px !important; height: 32px !important;
  }
  .s3-topbar .top-bar-icon-btn,
  .s3-topbar .tb-btn,
  .s3-topbar a.skip-main {
    height: 48px !important; min-height: 48px !important; min-width: 52px; padding-inline: .7rem !important;
  }
  .s3-topbar #langBtn .lang-glyph { font-size: 1.5rem; }
}

/* ---- 6. Compact header on phones / small tablets (inner pages) ----
   Before: three logos stacked = ~320px tall.  Now: emblem + Nation Tax Market logo on one row,
   department logo on the second row, search on the third (~170px). */
@media (max-width: 768px) {
  .s3-header { padding: 6px 0 !important; }
  .s3-header .header-inner {
    display: grid !important; grid-template-columns: 1fr 1fr !important;
    align-items: center; justify-items: center; gap: 6px 10px !important; padding-block: 0 !important;
  }
  .s3-header .header-end { display: contents !important; }                    /* its logo + search become grid items */
  .s3-header .header-inner .brand-left { grid-column: 1; grid-row: 1; justify-self: center; }
  .s3-header .header-inner .header-end > .logo-dept { grid-column: 2; grid-row: 1; justify-self: center; }
  .s3-header .header-inner .brand-center { grid-column: 1 / -1; grid-row: 2; flex-direction: row !important; gap: 8px !important; }
  .s3-header .header-inner .hdr-search { grid-column: 1 / -1; grid-row: 3; width: 100% !important; max-width: none !important; }
  /* max-height (not height) so logos keep their proportions on very narrow phones */
  .s3-header .header-inner .brand-left img { height: auto !important; max-height: 52px !important; width: auto; max-width: 100%; }
  .s3-header .header-inner .header-end .logo-dept img { height: auto !important; max-height: 44px !important; width: auto; max-width: 100%; }
  .s3-header .header-inner .brand-center img { height: auto !important; max-height: 52px !important; width: auto; max-width: 100%; }
}
@media (max-width: 360px) {
  .s3-header .header-inner .brand-center img { max-height: 44px !important; }
}

/* ---- 7. Data tables on phones: keep real column widths, scroll sideways inside a focusable region ----
   ctd-tables.js wraps every content table in <div class="table-scroll" role="region" tabindex="0">. */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-block: 1rem; border: 1px solid #C6C6C6; }
.table-scroll:focus-visible { outline: 3px solid #0D6EFD; outline-offset: 2px; }
.table-scroll > table { margin: 0; width: 100%; min-width: 44rem; }
.s3-main table th, .s3-main table td,
.s3-table th, .s3-table td {                 /* beat the site's own "overflow-wrap:anywhere" on table cells */
  min-width: 5rem; word-break: normal; overflow-wrap: break-word; hyphens: manual;
}
.s3-main table th:first-child, .s3-main table td:first-child { min-width: 3.5rem; }
.s3-main table td { vertical-align: middle; }
.s3-main table th { vertical-align: middle; }
.s3-main table select { max-width: 100%; }
@media (max-width: 768px) {
  .table-scroll > table { min-width: 40rem; }
  .s3-main table th, .s3-main table td { padding: 8px 10px; font-size: .9rem; }
}

/* ---- 8. Card pages (Gst_laws, Professional Tax, Pre-GST laws ...): .law-card-column / .law-card-body ----
   Bug: on phones the page sets  .law-card-column{height:auto}  but keeps  .law-card-body{flex:1 1 0; min-height:0}.
   A zero flex-basis adds no height to an auto-height card, so overflow:hidden clipped the whole list
   (only a thin sliver was visible). On phones the card must grow with its content and the PAGE scrolls. */
@media (max-width: 700px) {
  .law-card-column { height: auto !important; min-height: 0 !important; overflow: visible !important; }
  .law-card-body { flex: 0 0 auto !important; min-height: auto !important; overflow: visible !important; scrollbar-gutter: auto; }
  .law-card-scrollable { max-height: none !important; overflow: visible !important; }
}

/* ---- 9. "Swipe sideways" hint above scrolling tables (phones / small tablets only) ---- */
.table-hint { display: none; margin: .75rem 0 0; font-size: .8rem; font-weight: 600; color: #606060; }
@media (max-width: 768px) { .table-hint { display: block; } .table-hint::before { content: "\2194\00a0"; } }
@media print { .table-hint { display: none !important; } }

/* ---- 10. File cells (View + icon + size + PDF badge) must never overflow their column ----
   ctd-tables.js adds .has-file to any cell that links to a downloadable file.
   Fixed rem floor (Chrome does not honour min-width:max-content on table cells) + each piece is unbreakable,
   so the pieces wrap as units instead of spilling into the next column. */
.s3-main td.has-file { box-sizing: content-box; min-width: 12.5rem; vertical-align: middle; }
.s3-main td.has-file a, .s3-main td.has-file .file-badge, .s3-main td.has-file .file-size,
.s3-main td.has-file [class*="file-"] { white-space: nowrap; }
.s3-main td.has-file .file-badge { margin-left: .4rem; vertical-align: middle; }
.s3-main td.has-file img { vertical-align: middle; }
@media (max-width: 768px) {
  /* percentage / fixed column widths from the page cannot fit content on a phone: let columns size to their content */
  .table-scroll > table { table-layout: auto !important; width: auto !important; min-width: 100%; }
  .table-scroll th[style*="width"], .table-scroll td[style*="width"], .table-scroll col { width: auto !important; }
}

/* ---- 11. Neutralise the old "Mobile Viewport Reflow Guard" in ctd-gigw.css (max-width <= 480px) for tables ----
   That block sets  *{max-width:100% !important; box-sizing:border-box !important}  and  table{display:block !important}.
   Best fix: delete the block from ctd-gigw.css (patched copy provided). These rules protect tables if it stays. */
@media (max-width: 480px) {
  .table-scroll > table { display: table !important; overflow: visible !important; }
  .table-scroll table, .table-scroll th, .table-scroll td { max-width: none !important; }
  .s3-main td.has-file { box-sizing: content-box !important; min-width: 12.5rem; }
}

/* ---- 12. Phone card layout for simple tables (no sideways swipe) ----
   ctd-tables.js adds .table-cards to the wrapper and data-label to every cell of tables that qualify.
   Each row becomes a card: "Column heading : value". Tables with merged cells keep the scrolling region (+ hint).
   Opt a table out with data-scroll-only. Placed LAST and with .table-scroll.table-cards so it beats sections 7, 10, 11. */
@media (max-width: 768px) {
  .table-scroll.table-cards { overflow: visible; border: 0; margin-block: .75rem; }
  .table-scroll.table-cards > table,
  .table-scroll.table-cards > table > tbody,
  .table-scroll.table-cards > table > tbody > tr,
  .table-scroll.table-cards > table > tbody > tr > td,
  .table-scroll.table-cards > table > tbody > tr > th { display: block !important; }
  .table-scroll.table-cards > table { width: 100% !important; min-width: 0 !important; table-layout: auto !important; border: 0 !important; background: transparent; }
  /* header row hidden visually but still read by screen readers */
  .table-scroll.table-cards > table > thead { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
  .table-scroll.table-cards > table > tbody > tr {
    margin: 0 0 .85rem; background: #fff; border: 1px solid #C6C6C6; border-top: 3px solid #162F6A; border-radius: 8px; overflow: hidden;
  }
  .table-scroll.table-cards > table > tbody > tr > td,
  .table-scroll.table-cards > table > tbody > tr > th {
    display: grid !important; grid-template-columns: minmax(6rem, 38%) minmax(0, 1fr); gap: .25rem .75rem; align-items: start;
    width: auto !important; min-width: 0 !important; max-width: none !important; box-sizing: border-box;
    padding: .6rem .8rem !important; border: 0 !important; border-bottom: 1px solid #E4E4E4 !important;
    text-align: left !important; font-size: .95rem; overflow-wrap: anywhere; background: transparent;
  }
  .table-scroll.table-cards > table > tbody > tr > :last-child { border-bottom: 0 !important; }
  .table-scroll.table-cards > table > tbody > tr > [data-label]::before { content: attr(data-label); font-weight: 700; color: #162F6A; }
  .table-scroll.table-cards > table > tbody > tr > [data-label=""]::before { display: none; }
  .table-scroll.table-cards > table > tbody > tr > [data-label=""] { grid-template-columns: minmax(0, 1fr); }
  /* file cells: links may wrap inside the card instead of forcing a wide column */
  .table-scroll.table-cards td.has-file { min-width: 0 !important; }
  .table-scroll.table-cards td.has-file a { white-space: normal; }
  .table-scroll.table-cards select, .table-scroll.table-cards input { max-width: 100%; }
}
@media (max-width: 380px) {
  .table-scroll.table-cards > table > tbody > tr > td,
  .table-scroll.table-cards > table > tbody > tr > th { grid-template-columns: minmax(0, 1fr); }
}

/* ---- 13. Stable column widths at every window size (fixes "View + PDF icon + size" spilling into the next column) ----
   The page's own CSS uses table-layout:fixed / percentage widths taken from the first header row, so when the window
   narrows the file columns shrink below their content. Let the browser size columns from their content instead, and let
   the table scroll sideways inside its region when the window is narrower than the content. */
.table-scroll > table, .table-wrap > table, .s3-main table.s3-table {
  table-layout: auto !important;
}
.table-scroll > table th[style*="width"], .table-scroll > table td[style*="width"],
.table-wrap > table th[style*="width"], .table-wrap > table td[style*="width"],
.table-scroll > table col, .table-wrap > table col { width: auto !important; }
/* Half-screen / laptop / tablet (769px and wider): the whole table fits the page width, no sideways scroll when it can be avoided */
@media (min-width: 769px) {
  .table-scroll > table, .table-wrap > table { width: 100% !important; min-width: 0 !important; }
  .table-scroll > table th, .table-scroll > table td,
  .table-wrap > table th, .table-wrap > table td { overflow-wrap: normal; }
}
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
/* date, notification-number and file columns: stay on one line / keep their pieces together */
.s3-main td.has-file { min-width: 8rem !important; white-space: normal; }
.s3-main td.has-file a, .s3-main td.has-file .file-badge, .s3-main td.has-file .file-size,
.s3-main td.has-file [class*="file-"] { display: inline-block; white-space: nowrap; margin-block: .1rem; }
.s3-main table td, .s3-main table th { word-break: normal; }

/* ---- 14. Make the whole table fit half-screen windows / small laptops (769px - 1199px) ----
   File cells (View + PDF icon + size + PDF badge) stack vertically and centred, so these columns become narrow.
   Uses :has() on the PDF link as well, so it works even if ctd-tables.js has not marked the cell (.has-file). */
@media (min-width: 769px) and (max-width: 1199px) {
  .s3-main table td.has-file, .s3-main table td:has(a[href*=".pdf" i]) {
    min-width: 5.5rem !important; text-align: center; white-space: normal;
  }
  .s3-main table td.has-file a, .s3-main table td.has-file span, .s3-main table td.has-file small, .s3-main table td.has-file [class*="file-"],
  .s3-main table td:has(a[href*=".pdf" i]) a, .s3-main table td:has(a[href*=".pdf" i]) span, .s3-main table td:has(a[href*=".pdf" i]) small {
    display: block !important; width: fit-content; margin: .1rem auto !important; white-space: nowrap; text-align: center;
  }
  .table-scroll > table th, .table-scroll > table td, .table-wrap > table th, .table-wrap > table td { padding: 6px 5px; font-size: .88rem; }
  .table-scroll > table td:first-child, .table-wrap > table td:first-child { min-width: 2.5rem; }
}
/* Desktop / large laptop (1200px and wider): tables keep the site's normal text size and padding (nothing shrunk). */
