/* ==========================================================================
   Prime Focus - Standalone Android Legal Document System
   Optimized for Android Custom Chrome Tabs & In-App WebViews
   Inspired by Google, Stripe, GitHub, Apple, OpenAI Legal Documents
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  /* Color Palette */
  --bg-main: #F7F8FA;
  --bg-document: #FFFFFF;
  --color-primary: #0B57D0;
  --color-primary-hover: #0842A0;
  --color-text-main: #1F2937;
  --color-text-secondary: #6B7280;
  --color-text-muted: #9CA3AF;
  --color-border: #E5E7EB;
  --color-border-subtle: #F3F4F6;
  --bg-toc: #F9FAFB;

  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-size-body: 17px;
  --line-height-body: 1.8;

  /* Layout Limits */
  --doc-max-width: 900px;
  --doc-padding-desktop: 3rem 4rem;
  --doc-padding-tablet: 2.25rem 2.25rem;
  --doc-padding-mobile: 1.5rem 1.125rem; /* 18px horizontal padding */
  
  /* Shadow & Transitions */
  --shadow-document: 0 4px 24px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  --transition-fast: 0.15s ease-in-out;
}

/* Reset & Base Anti-Overflow Controls */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

html {
  font-family: var(--font-family);
  font-size: 16px;
  line-height: var(--line-height-body);
  color: var(--color-text-main);
  background-color: var(--bg-main);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
}

/* Text Wrapping & Safety */
p, li, h1, h2, h3, div, span, .doc-description {
  overflow-wrap: break-word;
  word-break: break-word;
}

a[href^="mailto:"], a[href^="http://"], a[href^="https://"], .toc-link, .doc-section a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

/* Touch Targets: minimum 44px height */
.toc-link, .doc-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* ==========================================================================
   Document Wrapper (Centered Single Document Layout)
   Minimal top padding for instant viewing on Android app launch
   ========================================================================== */
.main-wrapper {
  flex: 1;
  padding: 1.5rem 1.5rem 3.5rem;
  display: flex;
  justify-content: center;
}

.document-container {
  max-width: var(--doc-max-width);
  width: 100%;
  background: var(--bg-document);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-document);
  padding: var(--doc-padding-desktop);
}

/* ==========================================================================
   Document Brand Header (Replaces website navbar)
   ========================================================================== */
.doc-header {
  margin-bottom: 2.5rem;
}

.doc-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  color: #ffffff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
}

.doc-title {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--color-text-main);
  margin-bottom: 0.875rem;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

.doc-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.doc-meta-dot {
  color: var(--color-text-muted);
}

.doc-description {
  font-size: 1.0625rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.doc-header-divider {
  border: none;
  height: 1px;
  background-color: var(--color-border);
  margin-top: 1.5rem;
}

.text-center {
  text-align: center;
}

.justify-center {
  justify-content: center;
}

/* ==========================================================================
   Table of Contents (TOC)
   ========================================================================== */
.toc-container {
  background-color: var(--bg-toc);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.75rem 2rem;
  margin-bottom: 3rem;
}

.toc-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text-main);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.625rem 1.5rem;
}

.toc-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}

.toc-link:hover {
  text-decoration: underline;
  color: var(--color-primary-hover);
}

.toc-number {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  min-width: 1.5rem;
  flex-shrink: 0;
}

/* ==========================================================================
   Document Section Design
   ========================================================================== */
.doc-section {
  padding-top: 2rem;
  margin-bottom: 2.5rem;
  scroll-margin-top: 1.5rem;
}

.section-num {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
  margin-bottom: 0.75rem;
}

.section-divider {
  border: none;
  height: 1px;
  background-color: var(--color-border);
  margin-bottom: 1.5rem;
}

.doc-section p {
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  color: var(--color-text-main);
  margin-bottom: 1.25rem;
}

.doc-section p:last-child {
  margin-bottom: 0;
}

.doc-section h3 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text-main);
  margin: 1.75rem 0 0.625rem;
}

.doc-section ul {
  margin: 0.75rem 0 1.25rem 1.5rem;
  color: var(--color-text-main);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}

.doc-section li {
  margin-bottom: 0.5rem;
}

.doc-section li:last-child {
  margin-bottom: 0;
}

.doc-section strong {
  font-weight: 700;
  color: var(--color-text-main);
}

.doc-section a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.doc-section a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Home Directory Grid Styles
   ========================================================================== */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.home-grid-card {
  padding: 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background-color: var(--bg-toc);
  display: flex;
  flex-direction: column;
}

.home-grid-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.625rem;
  color: var(--color-text-main);
}

.home-grid-card p {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
  flex: 1;
}

.doc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  transition: var(--transition-fast);
  min-height: 44px;
}

.doc-btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

.doc-btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.doc-btn-secondary {
  background-color: #ffffff;
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
}

.doc-btn-secondary:hover {
  background-color: var(--bg-main);
  border-color: var(--color-text-secondary);
}

/* ==========================================================================
   Simple Standalone App Footer (No Navigation Links)
   ========================================================================== */
.app-doc-footer {
  background-color: var(--bg-main);
  border-top: 1px solid var(--color-border);
  padding: 2rem 1.5rem;
  margin-top: auto;
}

.footer-container {
  max-width: var(--doc-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  text-align: center;
}

.footer-copy {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.footer-app-info {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Tablet Responsive (769px to 1024px)
   ========================================================================== */
@media (max-width: 1024px) and (min-width: 769px) {
  .main-wrapper {
    padding: 1.25rem 1rem 3rem;
  }
  
  .document-container {
    max-width: 95%;
    padding: var(--doc-padding-tablet);
  }
  
  .doc-title {
    font-size: 36px;
  }

  .section-title {
    font-size: 26px;
  }
}

/* ==========================================================================
   Android Mobile Responsive (320px to 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .main-wrapper {
    padding: 0.5rem 0.5rem 2rem; /* Minimal top padding for Android in-app view */
  }

  .document-container {
    max-width: 100%;
    width: 100%;
    padding: var(--doc-padding-mobile); /* 18px horizontal padding */
    border-radius: 8px;
    box-shadow: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
  }

  /* Document Typography for Mobile */
  .doc-title {
    font-size: 30px; /* Fits 28px–32px requirement */
    line-height: 1.25;
  }

  .section-title {
    font-size: 23px; /* Fits 22px–24px requirement */
    line-height: 1.35;
  }

  .doc-section p, .doc-section ul {
    font-size: 16px;
    line-height: 1.75;
  }

  .doc-description {
    font-size: 0.9375rem;
    line-height: 1.7;
  }

  /* Table of Contents Stacking */
  .toc-container {
    padding: 1.25rem 1rem;
  }

  .toc-list {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .toc-link {
    width: 100%;
    padding: 0.25rem 0;
  }

  /* Metadata display */
  .doc-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .doc-meta-dot {
    display: none;
  }

  /* Button group stacking */
  .doc-btn {
    width: 100%;
  }
}

/* Extra Small Android Screens (320px to 375px e.g. Galaxy S8 / iPhone SE) */
@media (max-width: 375px) {
  .document-container {
    padding: 1.25rem 1rem; /* 16px horizontal padding */
  }

  .doc-title {
    font-size: 28px;
  }

  .section-title {
    font-size: 22px;
  }
}
