/* ============================================================
   ACCESSIBILITY.CSS — Keyboard Navigation & ARIA Styles
   Sri Harshita Pilla Portfolio
   ============================================================ */

/* ─────────────────────────────────────────────────────────
   FOCUS VISIBLE — Keyboard navigation indicator
   ───────────────────────────────────────────────────────── */

/* Global focus styles */
:focus-visible {
  outline: 2px solid var(--color-accent-orange);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent-orange);
  outline-offset: 2px;
}

/* Remove default browser outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ─────────────────────────────────────────────────────────
   SKIP TO MAIN LINK
   ───────────────────────────────────────────────────────── */

.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent-orange);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
}

.skip-to-main:focus {
  top: 0;
}

/* ─────────────────────────────────────────────────────────
   SCREEN READER ONLY TEXT
   ───────────────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ─────────────────────────────────────────────────────────
   REDUCED MOTION — Respect user preference
   ───────────────────────────────────────────────────────── */

@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;
  }
}

/* ─────────────────────────────────────────────────────────
   HIGH CONTRAST MODE — Ensure visibility
   ───────────────────────────────────────────────────────── */

@media (prefers-contrast: more) {
  :focus-visible {
    outline-width: 3px;
  }

  body {
    background-color: #000000;
    color: #FFFFFF;
  }

  var(--color-border) {
    border-color: #FFFFFF;
  }
}

/* ─────────────────────────────────────────────────────────
   BUTTONS — Accessible button styling
   ───────────────────────────────────────────────────────── */

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  /* Minimum touch target size: 44x44px for mobile */
  min-height: 44px;
  min-width: 44px;
}

button:hover {
  /* Indicate interactivity */
  text-decoration: none;
}

button[aria-disabled="true"],
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ─────────────────────────────────────────────────────────
   LINKS — Clear focus and hover states
   ───────────────────────────────────────────────────────── */

a {
  color: inherit;
  text-decoration: none;
  position: relative;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-accent-orange);
  outline-offset: 2px;
}

/* Indicate external links */
a[target="_blank"]::after {
  content: " (opens in new window)";
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ─────────────────────────────────────────────────────────
   FORM ELEMENTS — Accessible inputs
   ───────────────────────────────────────────────────────── */

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-accent-orange);
  outline-offset: -2px;
  border-color: var(--color-accent-orange);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--color-text-primary);
}

/* ─────────────────────────────────────────────────────────
   HEADINGS — Semantic HTML with proper hierarchy
   ───────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  /* Ensure sufficient color contrast */
  color: var(--color-text-primary);
  font-weight: 600;
  line-height: 1.3;
}

/* ─────────────────────────────────────────────────────────
   IMAGES — Alternative text
   ───────────────────────────────────────────────────────── */

img {
  /* All images should have descriptive alt text in HTML */
  display: block;
  max-width: 100%;
  height: auto;
}

img[alt=""],
img:not([alt]) {
  border: 2px solid red;
  /* Indicates missing alt text during development */
}

/* ─────────────────────────────────────────────────────────
   ICONS — Icon buttons with labels
   ───────────────────────────────────────────────────────── */

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-border-hover);
}

.icon-button:focus-visible {
  outline: 2px solid var(--color-accent-orange);
  outline-offset: 2px;
}

.icon-button svg {
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────
   LISTS — Proper semantic structure
   ───────────────────────────────────────────────────────── */

ul, ol {
  list-style-position: outside;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.5em;
}

/* ─────────────────────────────────────────────────────────
   COLOR CONTRAST — WCAG AA compliant
   ───────────────────────────────────────────────────────── */

/* Verify these contrast ratios:
   - Primary text (#FFF) on background (#0A0A0A): 17.0:1 ✅ (AAA)
   - Secondary text (rgba(255,255,255,0.55)) on bg: ~7.0:1 ✅ (AA)
   - Orange (#E8521A) on background: 3.4:1 ⚠️ (AA for large text, AAA for normal)
   - Orange (#E8521A) on white: 4.8:1 ✅ (AA)
*/

/* ─────────────────────────────────────────────────────────
   TABLES — Accessible table structure
   ───────────────────────────────────────────────────────── */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

thead {
  background: var(--color-surface);
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* ─────────────────────────────────────────────────────────
   MODALS — Accessible dialogs
   ───────────────────────────────────────────────────────── */

[role="dialog"] {
  position: fixed;
  z-index: 1000;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

[role="dialog"][aria-hidden="true"] {
  display: none;
}

/* ─────────────────────────────────────────────────────────
   TOOLTIPS — Accessible hover information
   ───────────────────────────────────────────────────────── */

[role="tooltip"] {
  position: absolute;
  background: var(--color-surface-2);
  color: var(--color-text-primary);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  /* Ensure visible on focus */
}

/* ─────────────────────────────────────────────────────────
   TEXT SELECTION — Readable selection
   ───────────────────────────────────────────────────────── */

::selection {
  background: var(--color-accent-orange);
  color: #FFFFFF;
}

::-moz-selection {
  background: var(--color-accent-orange);
  color: #FFFFFF;
}

/* ─────────────────────────────────────────────────────────
   SCROLLBAR — Optional custom scrollbar (accessible)
   ───────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

/* ─────────────────────────────────────────────────────────
   PRINT STYLES — For accessibility
   ───────────────────────────────────────────────────────── */

@media print {
  /* Hide interactive elements not needed for print */
  .navbar,
  .footer,
  button:not(.print-visible),
  nav {
    display: none;
  }

  /* Ensure readable text in print */
  body {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
  }

  /* Add URLs for external links in print */
  a[href]:after {
    content: " (" attr(href) ")";
  }
}
