/* ========================================
   Base Styles - Reset & Foundations
   MGH ED Patient Portal
   ======================================== */

/* Box sizing reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margins */
body,
h1, h2, h3, h4, h5, h6,
p,
ul, ol,
figure,
blockquote {
  margin: 0;
}

/* Remove default padding on lists */
ul, ol {
  padding: 0;
}

/* ========================================
   Body & Typography
   ======================================== */

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Headings
   ======================================== */

h1, h2, h3, h4 {
  line-height: var(--line-height-tight);
  color: var(--text);
}

h2 {
  font-size: var(--font-size-xl);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

h3 {
  font-size: var(--font-size-lg);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
}

h4 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-top: var(--space-sm);
  margin-bottom: var(--space-xs);
}

/* First heading inside accordion body should not have top margin */
.accordion-body > h3:first-child {
  margin-top: 0;
}

/* ========================================
   Paragraphs & Text
   ======================================== */

p {
  margin-bottom: var(--space-sm);
}

p:last-child {
  margin-bottom: 0;
}

strong {
  font-weight: 600;
}

em {
  color: var(--text-muted);
}

/* ========================================
   Links
   ======================================== */

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-hover);
}

a:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
  border-radius: var(--border-radius-sm);
}

/* External link indicator */
.external-link::after {
  content: " ↗";
  font-size: 0.85em;
}

/* Inline link buttons (styled as links but are buttons) */
.inline-link {
  background: none;
  border: none;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.inline-link:hover {
  color: var(--link-hover);
}

.inline-link:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
  border-radius: var(--border-radius-sm);
}

/* ========================================
   Lists
   ======================================== */

ul, ol {
  padding-left: var(--space-md);
  margin-bottom: var(--space-sm);
}

li {
  margin-bottom: var(--space-xs);
}

li:last-child {
  margin-bottom: 0;
}

/* Nested lists */
li > ul,
li > ol {
  margin-top: var(--space-xs);
  margin-bottom: 0;
}

/* ========================================
   Layout Container
   ======================================== */

.site-header,
main,
.site-footer {
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-xs);
  padding-right: var(--space-xs);
}

@media (min-width: 481px) {
  .site-header,
  main,
  .site-footer {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }
}

/* ========================================
   Focus Styles (Accessibility)
   ======================================== */

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

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

/* ========================================
   Skip Link (Accessibility)
   ======================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-sm);
  background: var(--brand-secondary);
  color: var(--text-on-brand);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-sm);
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: var(--space-xs);
}

/* ========================================
   Images
   ======================================== */

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========================================
   Selection
   ======================================== */

::selection {
  background-color: var(--brand-secondary);
  color: var(--text-on-brand);
}

/* ========================================
   RTL (Right-to-Left) Support
   Activated by Google Translate for Arabic, Urdu, etc.
   ======================================== */

[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] ul,
[dir="rtl"] ol {
  padding-left: 0;
  padding-right: var(--space-md);
}

[dir="rtl"] .skip-link {
  left: auto;
  right: var(--space-sm);
}

[dir="rtl"] .accordion-header {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .accordion-arrow::before {
  transform: rotate(-135deg);
}

[dir="rtl"] .accordion-header[aria-expanded="true"] .accordion-arrow::before {
  transform: rotate(45deg);
}

[dir="rtl"] .subsection summary {
  flex-direction: row-reverse;
}

[dir="rtl"] .subsection summary::after {
  margin-left: 0;
  margin-right: var(--space-sm);
  transform: rotate(-135deg);
}

[dir="rtl"] .subsection[open] summary::after {
  transform: rotate(45deg);
}

[dir="rtl"] .faq-item summary {
  flex-direction: row-reverse;
}

[dir="rtl"] .faq-item summary::after {
  margin-left: 0;
  margin-right: var(--space-sm);
  transform: rotate(-135deg);
}

[dir="rtl"] .faq-item[open] summary::after {
  transform: rotate(45deg);
}

[dir="rtl"] .zone-info-close {
  left: var(--space-xs);
  right: auto;
}

[dir="rtl"] .zone-info-title {
  padding-right: 0;
  padding-left: var(--min-touch-target);
}
