/* ============================================
   WCAG 2.1 AA Custom Styles
   SP ZOZ Lubartów
   ============================================ */

/* WCAG 2.4.1 - Skip Navigation */
.skip-link {
    position: absolute;
    left: -10000px;
    top: 0;
    background: #000000;
    color: #ffffff;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: bold;
    z-index: 999999;
    text-decoration: none;
    border: 2px solid #ffffff;
}

.skip-link:focus {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: auto !important;
    height: auto !important;
    outline: 3px solid #ffbf00 !important;
    outline-offset: 2px !important;
}

/* ============================================
   WCAG 2.4.6 / 2.4.5 - Breadcrumbs
   ============================================ */
.breadcrumb-wrapper {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.6rem 0;
}

.breadcrumb {
    font-size: 0.875rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: #64748b;
}

.breadcrumb-item a {
    color: #0f766e;
    text-decoration: none;
}

.breadcrumb-item a:hover,
.breadcrumb-item a:focus {
    text-decoration: underline;
}

.breadcrumb-item.active span {
    color: #1e293b;
}

/* Hide breadcrumbs from print — URL is enough context */
@media print {
    .breadcrumb-wrapper {
        display: none !important;
    }
}

/* ============================================
   Navbar — przyciski akcji (Portal wyników, eRejestracja)
   Własne klasy żeby uniknąć konfliktów z Bootstrap .btn
   ============================================ */
.navbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 4px 12px;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    cursor: pointer;
    border: 2px solid transparent;
}

.navbar-btn__icon {
    margin-left: 5px;
    flex-shrink: 0;
}

/* Between 1200-1366px there isn't room for the full "Portal wyników"
   label next to the widened menu — collapse it to an icon-only button
   (aria-label on the link still carries the accessible name). */
@media (min-width: 1200px) and (max-width: 1365.98px) {
    .navbar-btn__label {
        display: none;
    }

    .navbar-btn__icon {
        margin-left: 0;
    }
}

.navbar-btn--outline {
    background-color: transparent;
    border-color: #0f766e;
    color: #0f766e;
}

.navbar-btn--outline:hover,
.navbar-btn--outline:focus {
    background-color: #0f766e;
    color: #ffffff;
}

.navbar-btn--accent {
    background-color: #f59e0b;
    border-color: #f59e0b;
    color: #1e293b;
}

.navbar-btn--accent:hover,
.navbar-btn--accent:focus {
    background-color: #d97706;
    border-color: #d97706;
    color: #1e293b;
}

/* ============================================
   Navbar — Dropdown menus
   ============================================ */
.navbar .dropdown-menu {
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    min-width: 220px;
    padding: 0.5rem 0;
}

.navbar .dropdown-item {
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    color: #1e293b;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus {
    background-color: #f0fdfa;
    color: #0f766e;
}

.navbar .dropdown-item[aria-current="page"] {
    background-color: #f0fdfa;
    color: #0f766e;
    font-weight: 600;
}

/* WCAG 2.4.5 - Search form in navbar
   ============================================ */
.navbar-search .search-form .form-control {
    width: 180px;
    min-height: 36px;
    font-size: 0.875rem;
    padding: 4px 10px;
    transition: width 0.2s ease;
}

.navbar-search .search-form .form-control:focus {
    width: 240px;
}

.navbar-search .search-form .btn {
    min-height: 36px;
    padding: 4px 10px;
}

/* Mobile — full width inside collapsed menu */
@media (max-width: 1199.98px) {
    .navbar-btn {
        width: 100%;
        min-height: 44px;
        margin-left: 0 !important;
    }

    .navbar-search {
        width: 100%;
        margin: 0.5rem 0 0.25rem;
    }

    .navbar-search .search-form .form-control,
    .navbar-search .search-form .form-control:focus {
        width: 100%;
    }
}

/* WCAG 2.4.7 - Focus Indicators */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 3px solid #0066cc !important;
    outline-offset: 2px !important;
}

/* FIX: Navbar container padding - override Piranha default */
.navbar .container {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.navbar.fixed-top {
    min-height: auto !important;
}

/* Fix for fixed header (40px topbar + 64px navbar = 104px) */
main#main-content {
    padding-top: 0 !important;
    min-height: calc(100vh - 104px);
}

@media (max-width: 768px) {
    main#main-content {
        padding-top: 0 !important;
    }
}

/* ============================================
   WCAG 2.3.3 - Reduced Motion Support (AAA)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Accessibility panel - no slide animation */
    .accessibility-panel {
        transition: none !important;
    }

    /* Skip link - no animation */
    .skip-link {
        transition: none !important;
    }

    /* Navbar collapse - instant */
    .navbar-collapse {
        transition: none !important;
    }
}

/* ============================================
   WCAG 2.5.5 - Touch Target Size (AAA)
   Minimum 44x44px for all interactive elements
   ============================================ */

/* Buttons - ensure minimum size */
button,
.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 16px;
}

/* Links - standalone (not in paragraphs) */
a.btn,
a.navbar-brand,
.nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* Navbar toggler (burger button) */
.navbar-toggler {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
}

/* Accessibility toolbar button */
.accessibility-toggle {
    min-width: 48px !important;
    min-height: 48px !important;
}

/* Form inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
select,
textarea {
    min-height: 44px;
    padding: 8px 12px;
}

/* Checkboxes and radios - larger hit area */
input[type="checkbox"],
input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
}

/* Labels for checkboxes/radios - increase hit area */
input[type="checkbox"] + label,
input[type="radio"] + label {
    padding: 8px;
    cursor: pointer;
    display: inline-block;
    min-height: 44px;
    line-height: 28px;
}

/* Close buttons (modals, panels) */
.close,
.btn-close,
#accessibility-close {
    min-width: 44px !important;
    min-height: 44px !important;
}

/* Exception: inline text links can be smaller */
p a,
li a:not(.nav-link),
td a,
article a {
    min-width: auto;
    min-height: auto;
}

/* Ensure adequate spacing between touch targets */
.navbar-nav .nav-item {
    margin: 0 4px;
}

.accessibility-panel-content button {
    margin-bottom: 12px; /* Adequate spacing */
}

/* Mobile - increase touch targets further */
@media (max-width: 768px) {
    button,
    .btn,
    a.btn {
        min-height: 48px;
        padding: 12px 20px;
    }

    .navbar-toggler {
        min-width: 48px;
        min-height: 48px;
    }

    .nav-link {
        min-height: 48px;
        padding: 12px 16px;
    }
}

/* ============================================
   WCAG 1.4.12 - Text Spacing
   No content or functionality is lost when the
   user applies:
     line-height  ≥ 1.5× font-size
     letter-spacing ≥ 0.12em
     word-spacing   ≥ 0.16em
     paragraph spacing ≥ 2× font-size
   ============================================ */

/* Prevent long words / URLs from overflowing narrow containers */
body,
p, li, td, th, label, figcaption, blockquote {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Ensure text containers can grow — never clip text with fixed height.
   Topbar and navbar use min-height in _navbar.scss for the same reason. */
.entry-content *,
.footer-main *,
article * {
    max-height: none;
}

/* ============================================
   Print Styles - Accessible printing
   ============================================ */
@media print {
    /* Hide interactive elements - useless in print */
    .accessibility-toggle,
    .accessibility-panel,
    .skip-link {
        display: none !important;
    }

    /* Hide navigation - takes space */
    nav,
    .navbar,
    header {
        display: none !important;
    }

    /* Hide footer if it's just copyright */
    footer {
        display: none !important;
    }

    /* Main content - full width, no padding */
    main {
        padding-top: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Reset backgrounds - save ink */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    /* Links - show URL after link text */
    a[href]:not([href^="#"]):after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Email links - show email */
    a[href^="mailto:"]:after {
        content: " (" attr(href) ")";
    }

    /* Phone links - show number */
    a[href^="tel:"]:after {
        content: " (" attr(href) ")";
    }

    /* Images - ensure they fit page */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }

    /* Headings - keep with following content */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    /* Paragraphs - avoid orphans */
    p {
        orphans: 3;
        widows: 3;
    }

    /* Tables - keep together if possible */
    table {
        page-break-inside: avoid;
        border-collapse: collapse;
    }

    table th,
    table td {
        border: 1px solid #000;
        padding: 4px 8px;
    }

    /* Lists - avoid page break in middle */
    ul, ol {
        page-break-inside: avoid;
    }

    /* Code blocks - monospace, border */
    pre, code {
        border: 1px solid #000;
        page-break-inside: avoid;
        font-family: 'Courier New', monospace;
    }

    /* Add page header with title */
    @page {
        margin: 2cm;
    }

    /* First page - show title */
    body::before {
        content: attr(data-page-title);
        display: block;
        font-size: 24px;
        font-weight: bold;
        margin-bottom: 20px;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }

    body::after {
        content: "Wydrukowano: " attr(data-print-date);
        display: block;
        margin-top: 40px;
        font-size: 0.8em;
        color: #666;
        text-align: right;
    }
}