/* ============================================================================
   Onești City — Base styles
   Reset + typography + layout primitives. Depends on tokens.css.
   ========================================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* Headlines use serif for editorial civic-portal feel */
h1, h2, h3, .headline {
  font-family: var(--font-serif);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-4);
  font-weight: var(--fw-semibold);
}

h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  line-height: var(--lh-snug);
  margin: 0 0 var(--space-3);
  font-weight: var(--fw-semibold);
}

h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-base); }

@media (min-width: 768px) {
  h1 { font-size: var(--fs-5xl); }
  h2 { font-size: var(--fs-4xl); }
  h3 { font-size: var(--fs-2xl); }
}

p { margin: 0 0 var(--space-4); line-height: var(--lh-relaxed); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--trans-fast);
}
a:hover { color: var(--text-link-hover); text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
}
button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-6) 0;
}

::selection { background: var(--accent-500); color: #fff; }

/* ------- Layout primitives ------- */

.container {
  width: 100%;
  max-width: var(--content-default);
  margin: 0 auto;
  padding: 0 var(--space-4);
}
@media (min-width: 768px) {
  .container { padding: 0 var(--space-5); }
}
.container--wide { max-width: var(--content-wide); }
.container--full { max-width: var(--content-full); }
.container--narrow { max-width: var(--content-narrow); }

.section {
  padding: var(--space-7) 0;
}
@media (min-width: 768px) {
  .section { padding: var(--space-8) 0; }
}
.section--tight { padding: var(--space-5) 0; }

.stack > * + * { margin-top: var(--space-4); }
.stack--sm > * + * { margin-top: var(--space-2); }
.stack--lg > * + * { margin-top: var(--space-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.grid {
  display: grid;
  gap: var(--space-5);
}

/* Accessibility utility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--accent-600);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: var(--fw-semibold);
  z-index: var(--z-toast);
  transition: top var(--trans-fast);
}
.skip-link:focus {
  top: var(--space-3);
  text-decoration: none;
  color: #fff;
}

/* SPA navigation progress bar */
html[data-spa-loading]::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-700));
  z-index: calc(var(--z-toast) + 1);
  animation: spa-progress 800ms ease-in-out infinite;
  pointer-events: none;
}
@keyframes spa-progress {
  0%   { width: 0; }
  50%  { width: 80%; }
  100% { width: 100%; }
}

/* Typography helpers */
.eyebrow {
  text-transform: uppercase;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  color: var(--text-accent);
  margin: 0 0 var(--space-2);
  font-family: var(--font-sans);
}
.muted { color: var(--text-muted); }
.subtle { color: var(--text-secondary); }

/* ============================================================================
   Shared content modal (bulletins, sesizari, etc.)
   ========================================================================= */
@keyframes appModalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes appModalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Bulletin list — compact editorial cards used in widget + history */
.bulletin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.bulletin-list__item { margin: 0; }
.bulletin-list__btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  margin-left: calc(var(--space-3) * -1);
  color: inherit;
  cursor: pointer;
  font: inherit;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.bulletin-list__btn:hover,
.bulletin-list__btn:focus-visible {
  background: var(--surface-hover);
  border-left-color: var(--accent-600);
  outline: none;
}
.bulletin-list__btn:hover .bulletin-list__title,
.bulletin-list__btn:focus-visible .bulletin-list__title {
  color: var(--accent-600);
}
.bulletin-list__date {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}
.bulletin-list__date::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
  margin-left: var(--space-1);
}
.bulletin-list__title {
  display: block;
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--text-primary);
  margin: 0;
  transition: color 0.15s ease;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bulletin-list__stat {
  display: inline-block;
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Bulletin history — wider grid layout for /buletin page */
.bulletin-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .bulletin-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .bulletin-grid { grid-template-columns: repeat(3, 1fr); } }
.bulletin-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.bulletin-card:hover,
.bulletin-card:focus-visible {
  border-color: var(--accent-500);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  outline: none;
}
.bulletin-card__eyebrow {
  font-size: var(--fs-xs);
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-2);
}
.bulletin-card__title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bulletin-card__excerpt {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
  margin: 0 0 var(--space-4);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bulletin-card__footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--space-3);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.bulletin-card__stat strong { color: var(--text-primary); font-weight: var(--fw-semibold); }

.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay, rgba(0,0,0,0.6));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: appModalFadeIn 0.2s ease;
}
.app-modal {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: appModalSlideUp 0.25s ease;
}
.app-modal__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}
.app-modal__eyebrow {
  font-size: var(--fs-sm);
  color: var(--accent-600);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: 6px;
}
.app-modal__title {
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
  margin: 0;
  color: var(--text-primary);
}
.app-modal__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.app-modal__close:hover { background: var(--bg-elevated); transform: scale(1.05); }
.app-modal__media {
  background: var(--surface-sunken);
  max-height: 50vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-modal__media img { width: 100%; height: auto; max-height: 50vh; object-fit: contain; display: block; }
.app-modal__body {
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  color: var(--text-primary);
}
.app-modal__body--serif { font-family: var(--font-serif); font-size: var(--fs-lg); }
.app-modal__body p { margin: 0 0 var(--space-4); }
.app-modal__body p:last-child { margin-bottom: 0; }
.app-modal__body.is-loading { color: var(--text-muted); font-style: italic; }
.app-modal__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.app-modal__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.app-modal__lede {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: var(--lh-relaxed);
  color: var(--text-primary);
  margin: 0 0 var(--space-5);
}
.app-modal__facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3) var(--space-5);
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}
@media (min-width: 520px) { .app-modal__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.app-modal__facts > div { display: flex; flex-direction: column; gap: 2px; }
.app-modal__facts dt {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}
.app-modal__facts dd { margin: 0; font-size: var(--fs-sm); color: var(--text-primary); }
.app-modal__facts .muted { color: var(--text-muted); }

/* Gallery for multi-image sesizari */
.app-modal__gallery { background: #000; }
.app-modal__gallery-stage {
  position: relative;
  max-height: 50vh;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.app-modal__gallery-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.app-modal__gallery-stage img.is-active { opacity: 1; position: relative; }
.app-modal__gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s ease;
}
.app-modal__gallery-nav:hover { background: rgba(0,0,0,0.85); }
.app-modal__gallery-nav--prev { left: var(--space-3); }
.app-modal__gallery-nav--next { right: var(--space-3); }
.app-modal__gallery-count {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  z-index: 2;
}

@media (max-width: 640px) {
  .app-modal-overlay { padding: 0; align-items: stretch; }
  .app-modal { max-height: 100vh; border-radius: 0; max-width: 100%; }
  .app-modal__title { font-size: var(--fs-xl); }
}
