/*
 * Pokala Law APC
 *
 * FILE:
 * public/assets/css/theme.css
 *
 * PURPOSE:
 * The stylesheet of the theme layer (app/includes/theme.php, docs/design/THEME.md),
 * STAGED FOR REVIEW since 2026-11-21: loaded only inside the password protected
 * preview, or on the public site with THEME=on in .env.
 *   1. The dark mode switch in the header.
 *   2. The header that stays at the top of the window and shrinks after scrolling.
 *   3. Dark mode: the base (page surface, text), the site's own parts (forms, short
 *      form, bars, notices: the rules of site.css and convert.css), and the
 *      exceptions that the generated dark stylesheets cannot know.
 *
 * HOW DARK MODE IS PUT TOGETHER:
 *   <html data-theme="dark"> is set by a few lines of script in the head before the
 *   page is drawn. The colors of the old theme's stylesheets are turned by GENERATED
 *   files (public/assets/lite/dark, tools/build_dark_css.js); this file holds what is
 *   written by hand. Every dark rule here starts with html[data-theme="dark"].
 *
 * THE PALETTE (the same values are at the top of tools/build_dark_css.js):
 *   --pl-d-surface  #10161f  the page
 *   --pl-d-raised   #18212d  panels, cards, form fields
 *   --pl-d-raised2  #212c3a  the lightest dark surface
 *   --pl-d-text     #e6eaf0  text            15.0 to 1 on the page
 *   --pl-d-muted    #c3cad4  quieter text    10.9 to 1 on the page
 *   --pl-d-link     #9fcbf7  links in text    10.4 to 1 on the page
 *   --pl-d-border   #5b6878  borders          3.1 to 1 on the page (WCAG 1.4.11)
 *   --pl-d-focus    #ffd166  the focus ring   12.3 to 1 on the page
 *
 * ACCESSIBILITY (checked by tests/accessibility/axe_full_audit.js with THEME=dark and
 * tests/accessibility/manual_checks.js with ONLY=theme):
 *   - text contrast at least 4.5 to 1, large text and controls at least 3 to 1;
 *   - the switch is a real <button> with a name and a pressed state, 44 by 44 pixels
 *     to touch, with a visible focus ring;
 *   - the sticky header never covers the control that has the keyboard focus
 *     (scroll-padding-top), and lets go of the top on short windows (phones held
 *     sideways, 400 percent zoom) so that it cannot fill the screen;
 *   - nothing moves for visitors who ask for reduced motion.
 *
 * MODIFICATION GUIDE:
 *   - A new color pair in dark mode: check its contrast first, then run the two checks
 *     named above.
 *   - The palette: change it here AND in tools/build_dark_css.js, then run that tool.
 *
 * RELATED DOCUMENTATION:
 *   docs/design/THEME.md
 */

/* 1. The switch ------------------------------------------------------------------- */
body.pl-theme button.pl-theme-switch {
    -webkit-appearance: none;
    appearance: none;
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    box-sizing: border-box;
    color: #fff;                       /* the header is dark in both modes */
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    height: 44px;                      /* WCAG 2.5.5 / 2.5.8: room to touch */
    justify-content: center;
    line-height: 1;
    margin: 0;
    opacity: 0.72;                     /* subtle until pointed at or focused */
    padding: 0;
    width: 44px;
}
.pl-theme-switch[hidden] { display: none !important; }
.pl-theme-switch svg { display: block; pointer-events: none; }
body.pl-theme button.pl-theme-switch:hover, body.pl-theme button.pl-theme-switch:focus { background: rgba(255, 255, 255, 0.12); border-color: transparent; color: #fff; opacity: 1; }
body.pl-theme button.pl-theme-switch:focus-visible { outline: 2px solid #ffd166; outline-offset: 2px; opacity: 1; }
.pl-theme-switch .pl-theme-sun { display: none; }
html[data-theme="dark"] .pl-theme-switch .pl-theme-sun { display: block; }
html[data-theme="dark"] .pl-theme-switch .pl-theme-moon { display: none; }

/* Where each copy is shown. The contact bar exists from 1026 pixels up and is put away
   when the header shrinks; the copy in the logo row takes over in both cases. */
body.pl-theme button.pl-theme-switch--bar { order: 100000; margin-left: 2px; height: 36px; width: 36px; }
body.pl-theme button.pl-theme-switch--row { display: none; margin-left: 10px; }
html.pl-condensed body.pl-theme button.pl-theme-switch--row { display: inline-flex; }
/* Shrunk on a wide screen: the menu keeps to the right, the switch after it. */
html.pl-condensed body.pl-theme .elementor-location-header .elementor-element-3bd72d9 { margin-left: auto; }
@media (max-width: 1025px) {
    body.pl-theme button.pl-theme-switch--row { display: inline-flex; order: 2; margin-left: auto; margin-right: 4px; }
    body.pl-theme .elementor-location-header .elementor-element-3bd72d9 { order: 3; margin-left: 0; }
}

/* 2. The header stays at the top and shrinks ------------------------------------------ */
body.pl-theme header.elementor-location-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 9000;                     /* above the page, below the bars at the bottom (9990) and the notice (9995) */
}
/* What the keyboard focus scrolls to must not end under the header (WCAG 2.2, 2.4.11).
   --pl-header-h is the measured height of the header (theme.js). */
html:has(body.pl-theme) { scroll-padding-top: calc(var(--pl-header-h, 96px) + 12px); }

/* Shrunk: the contact bars are put away, the logo row gets tighter. The switch between
   the two states is instant on purpose: theme.js keeps the page below from jumping by
   giving the header a bottom margin of exactly the height it lost. */
html.pl-condensed body.pl-theme .elementor-location-header .elementor-element-c982571,
html.pl-condensed body.pl-theme .elementor-location-header .elementor-element-062704e { display: none; }
html.pl-condensed body.pl-theme .elementor-location-header .elementor-element-59c355b {
    --padding-top: 6px;
    --padding-bottom: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
html.pl-condensed body.pl-theme .elementor-location-header .elementor-element-9952cb3 img { height: 40px; width: auto; }
html.pl-condensed body.pl-theme .elementor-location-header .elementor-element-9952cb3 > .elementor-widget-container { padding-bottom: 0; }
@media (prefers-reduced-motion: no-preference) {
    body.pl-theme .elementor-location-header .elementor-element-59c355b { transition: box-shadow 0.2s ease; }
}
/* The opened menu on phones must fit below the header and scroll inside itself. */
@media (max-width: 1025px) {
    body.pl-theme .elementor-location-header .elementor-nav-menu--dropdown.elementor-nav-menu__container {
        max-height: calc(100vh - var(--pl-header-h, 96px));
        max-height: calc(100dvh - var(--pl-header-h, 96px));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}
/* A short window (a phone held sideways, or a desktop at 400 percent zoom): a header
   that stays would take most of the screen (WCAG 1.4.10 Reflow). It lets go. */
@media (max-height: 480px) {
    body.pl-theme header.elementor-location-header { position: static; }
    html:has(body.pl-theme) { scroll-padding-top: 0; }
}
@media print {
    body.pl-theme header.elementor-location-header { position: static; }
    .pl-theme-switch { display: none !important; }
}

/* 3. Dark mode: the base ---------------------------------------------------------------- */
html[data-theme="dark"] {
    --pl-d-surface: #10161f;
    --pl-d-raised: #18212d;
    --pl-d-raised2: #212c3a;
    --pl-d-text: #e6eaf0;
    --pl-d-muted: #c3cad4;
    --pl-d-link: #9fcbf7;
    --pl-d-border: #5b6878;
    --pl-d-focus: #ffd166;
    color-scheme: dark;                /* the browser's own parts: scroll bars, date pickers, select lists */
}
html[data-theme="dark"] body { background-color: var(--pl-d-surface); color: var(--pl-d-muted); }
/* While the mode changes, nothing fades: one instant change (public/assets/js/theme.js). */
html.pl-theme-switching *, html.pl-theme-switching *::before, html.pl-theme-switching *::after { transition: none !important; }
/* Dark blue buttons on the dark page keep an edge that can be seen (WCAG 1.4.11). */
html[data-theme="dark"] body.pl-theme .elementor-button, html[data-theme="dark"] body.pl-theme button[type="submit"],
html[data-theme="dark"] body.pl-theme .pl-hero-button { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }
html[data-theme="dark"] body.pl-theme :focus-visible { outline-color: var(--pl-d-focus); }
html[data-theme="dark"] body.pl-theme hr { border-color: var(--pl-d-border); }
html[data-theme="dark"] body.pl-theme blockquote { border-color: var(--pl-d-border); color: var(--pl-d-text); }
html[data-theme="dark"] body.pl-theme table td, html[data-theme="dark"] body.pl-theme table th { border-color: var(--pl-d-border); }
html[data-theme="dark"] body.pl-theme table tbody > tr:nth-child(odd) > td, html[data-theme="dark"] body.pl-theme table tbody > tr:nth-child(odd) > th { background-color: var(--pl-d-raised); }
html[data-theme="dark"] body.pl-theme table tbody tr:hover > td, html[data-theme="dark"] body.pl-theme table tbody tr:hover > th { background-color: var(--pl-d-raised2); }
/* Colors written into the text itself by the old editor. */
html[data-theme="dark"] body.pl-theme [style*="color: #000000"], html[data-theme="dark"] body.pl-theme [style*="color:#000000"],
html[data-theme="dark"] body.pl-theme [style*="color: black"], html[data-theme="dark"] body.pl-theme [style*="color:black"] { color: var(--pl-d-text) !important; }
/* Pictures keep their colors; a hair less glare. */
html[data-theme="dark"] body.pl-theme main img, html[data-theme="dark"] body.pl-theme article img { filter: brightness(0.94); }

/* 4. Dark mode: the site's own parts (site.css) ------------------------------------------ */
html[data-theme="dark"] .skip-link.screen-reader-text:focus { background: var(--pl-d-raised2); color: var(--pl-d-text); outline: 2px solid var(--pl-d-focus); }
/* Forms */
html[data-theme="dark"] body.pl-theme input[type="text"], html[data-theme="dark"] body.pl-theme input[type="email"],
html[data-theme="dark"] body.pl-theme input[type="tel"], html[data-theme="dark"] body.pl-theme input[type="date"],
html[data-theme="dark"] body.pl-theme input[type="time"], html[data-theme="dark"] body.pl-theme input[type="search"],
html[data-theme="dark"] body.pl-theme input[type="url"], html[data-theme="dark"] body.pl-theme input[type="number"],
html[data-theme="dark"] body.pl-theme select, html[data-theme="dark"] body.pl-theme textarea {
    background-color: var(--pl-d-raised);
    border-color: var(--pl-d-border);
    color: var(--pl-d-text);
}
html[data-theme="dark"] body.pl-theme ::placeholder { color: #a9b3c0; opacity: 1; }       /* 7.7 to 1 on the field */
html[data-theme="dark"] body.pl-theme label, html[data-theme="dark"] body.pl-theme legend { color: var(--pl-d-text); }
html[data-theme="dark"] body.pl-theme .pl-form-errors, html[data-theme="dark"] body.pl-theme .pl-form-error,
html[data-theme="dark"] body.pl-theme .pl-field-error { color: #ffb3bd; }               /* 9.6 to 1 */
html[data-theme="dark"] body.pl-theme .pl-form-errors { background: #3a1820; border-color: #ff8fa0; }
html[data-theme="dark"] body.pl-theme .pl-form-errors a { color: #ffd6dc; }
html[data-theme="dark"] body.pl-theme [aria-invalid="true"] { border-color: #ff8fa0; }
html[data-theme="dark"] body.pl-theme .pl-form-note, html[data-theme="dark"] body.pl-theme .pl-form-hint { color: var(--pl-d-muted); }

/* 5. Dark mode: the conversion parts (convert.css) ------------------------------------- */
html[data-theme="dark"] .pl-preview-strip { background: #3b3211; border-bottom-color: #8a7422; color: #ffe9a8; }
html[data-theme="dark"] .pl-lead, html[data-theme="dark"] .pl-lead-card { background-color: var(--pl-d-raised); border-color: var(--pl-d-border); color: var(--pl-d-muted); }
html[data-theme="dark"] .pl-lead h2, html[data-theme="dark"] .pl-lead h3, html[data-theme="dark"] .pl-lead label { color: var(--pl-d-text); }
html[data-theme="dark"] .pl-lead a { color: var(--pl-d-link); }
/* The gold buttons stay gold with dark blue words (5.6 to 1). The tool turned the words
   light because their color and the gold are named in two different rules. */
html[data-theme="dark"] body.pl-theme .pl-cta a.pl-cta-button, html[data-theme="dark"] body.pl-theme .pl-cta a.pl-cta-button:visited { background: #b6a075; color: #102b4b; }
html[data-theme="dark"] body.pl-theme .pl-cta a.pl-cta-button:hover, html[data-theme="dark"] body.pl-theme .pl-cta a.pl-cta-button:focus { background: #c7b48d; color: #102b4b; }
@media (max-width: 767px) {
    html[data-theme="dark"] .pl-callbar { background: var(--pl-d-raised); }
    html[data-theme="dark"] .pl-callbar a.pl-callbar-appointment, html[data-theme="dark"] .pl-callbar a.pl-callbar-appointment:hover {
        background: var(--pl-d-raised); border-top-color: #9fcbf7; color: #e6eaf0;
    }
    html[data-theme="dark"] .pl-callbar a:focus { outline-color: var(--pl-d-focus); }
}
