/* =====================================================================
   DESIGN SYSTEM & ACCESSIBILITY-FIRST STYLESHEET
   Aplicația Web: Fizica de lângă noi (CES)
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&family=Comic+Neue:wght@400;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* PALETĂ PASTEL CALMĂ (Inspirată direct din LaTeX) */
  --bg-cream: #FDFAF0;
  
  --pale-blue: #A8D8EA;
  --pale-blue-dark: #5F9EB8;
  --pale-blue-bg: rgba(168, 216, 234, 0.15);
  
  --pale-mint: #C1E1C1;
  --pale-mint-dark: #64A06E;
  --pale-mint-bg: rgba(193, 225, 193, 0.18);
  
  --pale-yellow: #FFF4A3;
  --pale-yellow-dark: #C8A032;
  --pale-yellow-bg: rgba(255, 244, 163, 0.22);
  
  --pale-pink: #F8C8DC;
  --pale-pink-dark: #C86E96;
  --pale-pink-bg: rgba(248, 200, 220, 0.18);
  
  --pale-lavender: #D8BFD8;
  --pale-lavender-dark: #8C64A0;
  --pale-lavender-bg: rgba(216, 191, 216, 0.18);
  
  --pale-apricot: #FFDAB9;
  --pale-apricot-dark: #D28C50;
  --pale-apricot-bg: rgba(255, 218, 185, 0.18);
  
  --text-gray: #37373C;
  --text-light: #5A5A60;
  --white: #FFFFFF;
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 20px rgba(55, 55, 60, 0.05);
  --border-calm: rgba(55, 55, 60, 0.08);
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  
  /* DIMENSIUNI TEXT DINAMICE */
  --font-base: 18px;
  --font-multiplier: 1;
  
  /* TIPOGRAFIE PREDEFINITĂ */
  --font-family-primary: 'Outfit', sans-serif;
  --font-family-dyslexic: 'Atkinson Hyperlegible', sans-serif;
  --font-family-friendly: 'Comic Neue', cursive, sans-serif;
  --font-active: var(--font-family-primary);
  
  /* TRANZIȚII FLUIDE */
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* HIGH CONTRAST THEME OVERRIDES */
body.high-contrast {
  --bg-cream: #FFFFFF;
  --text-gray: #000000;
  --text-light: #111111;
  --border-calm: #000000;
  --pale-blue-bg: #E8F4F8;
  --pale-mint-bg: #E8F5E8;
  --pale-yellow-bg: #FFFDF0;
  --pale-pink-bg: #FFF0F5;
  --pale-lavender-bg: #F9F0F9;
  --pale-apricot-bg: #FFF5EE;
  --pale-blue-dark: #004D61;
  --pale-mint-dark: #005A1A;
  --pale-yellow-dark: #664E00;
  --pale-pink-dark: #7A003D;
  --pale-lavender-dark: #4A0066;
  --pale-apricot-dark: #753300;
  --shadow-soft: none;
  --shadow-card: none;
}

/* GENERAL RESET */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-active);
  font-size: calc(var(--font-base) * var(--font-multiplier));
  color: var(--text-gray);
  background-color: var(--bg-cream);
  line-height: 1.6;
  letter-spacing: 0.01em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* Eliminarea chenarului de focalizare (outline) pentru elementele focalizate programatic (e.g. titluri de pagină) */
[tabindex="-1"]:focus {
  outline: none;
}

/* CELE TREI MODURI DE FONTURI ACCESIBILE */
body.font-outfit {
  --font-active: var(--font-family-primary);
}

body.font-dyslexic {
  --font-active: var(--font-family-dyslexic);
  letter-spacing: 0.03em;
  word-spacing: 0.12em;
}

body.font-comic {
  --font-active: var(--font-family-friendly);
  letter-spacing: 0.02em;
  word-spacing: 0.08em;
  font-weight: 500;
}

/* NATIVE SCROLLBARS */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--pale-blue-dark);
  border-radius: 6px;
  border: 3px solid var(--bg-cream);
}

::-webkit-scrollbar-thumb:hover {
  background: #4A8FA9;
}

/* SEMANTIC LANDMARKS & CONTAINERS */
header {
  background: var(--white);
  border-bottom: 1px solid var(--border-calm);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.logo-container h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--pale-blue-dark);
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--pale-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}

/* ACCESSIBILITY PANEL */
.accessibility-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-btn {
  background: var(--bg-cream);
  border: 1px solid var(--border-calm);
  color: var(--text-gray);
  padding: 8px 14px;
  border-radius: var(--border-radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.acc-btn:hover, .acc-btn:focus-visible {
  background: var(--white);
  border-color: var(--pale-blue-dark);
  color: var(--pale-blue-dark);
  outline: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.acc-btn.active {
  background: var(--pale-blue-dark);
  color: var(--white);
  border-color: var(--pale-blue-dark);
}

/* LAYOUT: SIDEBAR + MAIN AREA */
.app-container {
  display: flex;
  flex: 1;
  width: 100%;
  position: relative;
}

/* SIDEBAR (Lista de teme) */
.sidebar {
  width: 320px;
  border-right: 1px solid var(--border-calm);
  background: var(--white);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  height: calc(100vh - 75px);
  position: sticky;
  top: 75px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s ease;
}

/* Starea extinsă (pe desktop) */
@media (min-width: 993px) {
  .sidebar.expanded {
    width: 500px;
  }
  
  .sidebar.expanded .sidebar-link-text {
    max-width: 410px;
    white-space: normal;
  }
}

/* Starea extinsă (pe mobil) */
@media (max-width: 992px) {
  .sidebar.expanded .sidebar-link-text {
    max-width: 100%;
    white-space: normal;
  }
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-gray);
  padding: 0 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-item {
  width: 100%;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  text-decoration: none;
  color: var(--text-gray);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  border: 1px solid transparent;
  transition: var(--transition-smooth);
  width: 100%;
  background: transparent;
  cursor: pointer;
}

.sidebar-link-text {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 230px;
  transition: max-width 0.3s ease;
  vertical-align: middle;
}

.sidebar-link:hover, .sidebar-link:focus-visible {
  background: var(--bg-cream);
  border-color: var(--border-calm);
  outline: none;
}

.sidebar-link.active {
  background: var(--pale-blue-bg);
  color: var(--pale-blue-dark);
  border-color: var(--pale-blue);
  font-weight: 600;
}

.sidebar-link.completed::after {
  content: '✔';
  color: var(--pale-mint-dark);
  font-size: 0.9rem;
  margin-left: 8px;
}

/* MAIN CONTENT AREA */
main {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto;
  height: calc(100vh - 75px);
  background: var(--bg-cream);
}

.content-wrapper {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* DASHBOARD / HOME LANDING PAGE */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-top: 1.5rem;
}

.section-card {
  background: var(--white);
  border: 1px solid var(--border-calm);
  border-radius: var(--border-radius-lg);
  padding: 1.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.section-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: var(--card-color, var(--pale-blue));
}

.section-card:hover, .section-card:focus-within {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(55, 55, 60, 0.08);
  border-color: var(--card-color, var(--pale-blue-dark));
  outline: none;
}

.section-img-wrapper {
  width: 100%;
  height: 180px;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background: var(--bg-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-calm);
}

.section-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-gray);
  margin-top: 0.2rem;
}

.section-card p {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.5;
}

.progress-container {
  background: var(--bg-cream);
  height: 12px;
  border-radius: 6px;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-calm);
  position: relative;
}

.progress-bar {
  background: var(--card-color-dark, var(--pale-blue-dark));
  height: 100%;
  border-radius: 6px;
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
}

/* TOPIC CONTENT DESIGN */
.topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 2px dashed var(--border-calm);
  padding-bottom: 1.5rem;
}

.topic-title-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topic-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--header-theme-bg, var(--pale-blue-bg));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--header-theme-border, var(--pale-blue));
}

.topic-icon svg, .topic-icon img {
  width: 32px;
  height: 32px;
}

.topic-title-area h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-gray);
  letter-spacing: -0.02em;
}

.topic-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 4-BOX LAYOUT FOR THEME CONTENT */
.boxes-container {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.calm-box {
  background: var(--box-bg);
  border: 1.5px solid var(--box-border);
  border-radius: var(--border-radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow-soft);
  position: relative;
  transition: var(--transition-smooth);
}

.calm-box:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.box-title {
  display: inline-block;
  background: var(--box-title-bg);
  border: 1px solid var(--box-border);
  color: var(--box-title-color);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 700;
  position: absolute;
  top: -16px;
  left: 24px;
  box-shadow: var(--shadow-card);
}

.box-content {
  margin-top: 0.6rem;
  color: var(--text-gray);
}

.box-content p {
  margin-bottom: 0.8rem;
}

.box-content p:last-child {
  margin-bottom: 0;
}

/* LIST STYLING IN BOXES */
.box-content ul {
  list-style: none;
  padding-left: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0.5rem;
}

.box-content li {
  position: relative;
  padding-left: 1.5rem;
  line-height: 1.5;
}

.box-content li::before {
  content: '•';
  color: var(--box-title-color);
  font-size: 1.8rem;
  position: absolute;
  left: 0;
  top: -6px;
}

/* INDIVIDUAL BOX THEME COLOR ASSIGNMENTS */
.box-ce-vedem, .box-situatie {
  --box-bg: var(--pale-blue-bg);
  --box-border: var(--pale-blue-dark);
  --box-title-bg: var(--pale-blue);
  --box-title-color: var(--pale-blue-dark);
}

.box-de-ce, .box-grija {
  --box-bg: var(--pale-mint-bg);
  --box-border: var(--pale-mint-dark);
  --box-title-bg: var(--pale-mint);
  --box-title-color: var(--pale-mint-dark);
}

.box-acasa, .box-feresti {
  --box-bg: var(--pale-yellow-bg);
  --box-border: var(--pale-yellow-dark);
  --box-title-bg: var(--pale-yellow);
  --box-title-color: var(--pale-yellow-dark);
}

.box-retinut {
  --box-bg: var(--pale-pink-bg);
  --box-border: var(--pale-pink-dark);
  --box-title-bg: var(--pale-pink);
  --box-title-color: var(--pale-pink-dark);
}

/* ACTION BUTTONS */
.btn-large {
  background: var(--white);
  border: 2px solid var(--pale-mint-dark);
  color: var(--pale-mint-dark);
  padding: 14px 28px;
  border-radius: var(--border-radius-lg);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
}

.btn-large:hover, .btn-large:focus-visible {
  background: var(--pale-mint-dark);
  color: var(--white);
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(100, 160, 110, 0.2);
}

.btn-large.checked {
  background: var(--pale-mint-dark);
  color: var(--white);
}

/* TOPIC NAVIGATION (Paginare jos) */
.topic-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-calm);
  padding-top: 1.5rem;
}

.topic-nav-btn {
  flex: 1;
  max-width: 45%;
  justify-content: center;
  white-space: normal;
  text-align: center;
}

.topic-nav-btn-home {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .topic-navigation {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
  }
  
  .topic-nav-btn {
    max-width: 100%;
    width: 100%;
  }
  
  .topic-nav-btn-home {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  
  .topic-navigation div {
    display: none;
  }
}

/* FOOTER LANDMARK */
footer {
  background: var(--white);
  border-top: 1px solid var(--border-calm);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: auto;
}

.heart-icon {
  display: inline-block;
  cursor: default;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
  filter: grayscale(20%) brightness(0.95);
}

.heart-icon:hover {
  transform: scale(1.4) rotate(8deg);
  filter: grayscale(0%) brightness(1.2) drop-shadow(0 0 8px rgba(255, 50, 50, 0.8));
}

/* VIEW TRANSITIONS API PAIRING */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.25s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESPONSIVE LAYOUT */
@media (max-width: 992px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 250px;
    position: relative;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border-calm);
  }
  
  main {
    height: auto;
    padding: 1.5rem;
  }
}

@media (max-width: 600px) {
  header {
    padding: 0.8rem 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  
  .accessibility-bar {
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
  }
  
  .topic-title-area h2 {
    font-size: 1.4rem;
  }
  
  .topic-icon {
    width: 48px;
    height: 48px;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .calm-box {
    padding: 1.5rem 1.2rem;
  }
  
  .box-title {
    font-size: 0.85rem;
    left: 16px;
    padding: 4px 12px;
  }
}

/* ACCESSIBILITY ROUTING HIDDEN HEADINGS */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* DE-TABBING INACTIVE VIEWS STYLING */
[inert] {
  opacity: 0.4;
  pointer-events: none;
}

/* REDUCED MOTION RESPONDING */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  
  *, *::before, *::after {
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}
