/* =========================================================================
   Organisation 4R — editorial minimalist
   Login = pure breath, two horizontal rules framing the title + password.
   Dashboard = same vocabulary, sectioned, with style.
   ========================================================================= */

:root {
  /* Canvas */
  --bg:               #000000;
  --bg-elev:          #0a0b0d;

  /* Text */
  --text:             #ffffff;
  --text-muted:       rgba(255, 255, 255, 0.65);
  --text-dim:         rgba(255, 255, 255, 0.42);
  --text-faint:       rgba(255, 255, 255, 0.24);
  --text-ghost:       rgba(255, 255, 255, 0.08);
  --text-stroke:      rgba(255, 255, 255, 0.22);

  /* Surfaces */
  --glass:            rgba(255, 255, 255, 0.025);
  --glass-hover:      rgba(255, 255, 255, 0.05);

  /* Borders */
  --border:           rgba(255, 255, 255, 0.10);
  --border-soft:      rgba(255, 255, 255, 0.06);
  --border-strong:    rgba(255, 255, 255, 0.20);

  /* Accent (interactive only) */
  --accent:           #5e6ad2;
  --accent-glow:      rgba(94, 106, 210, 0.28);

  /* Status */
  --ok:               #4ade80;
  --warn:             #fbbf24;
  --error:            #f87171;
  --info:             #60a5fa;
  --down:             rgba(255, 255, 255, 0.32);
  --ok-glow:          rgba(74, 222, 128, 0.32);
  --warn-glow:        rgba(251, 191, 36, 0.32);
  --error-glow:       rgba(248, 113, 113, 0.32);

  /* Typography */
  --font-sans:        'Space Grotesk', -apple-system, system-ui, sans-serif;
  --font-mono:        'Space Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* Motion */
  --ease:             cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:         150ms;
  --dur-base:         260ms;
  --dur-slow:         440ms;

  /* Frame gutter (the breathing room) */
  --gutter-x:         clamp(20px, 5vw, 56px);
  --gutter-y:         clamp(20px, 3.5vw, 36px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  letter-spacing: 0.06em;
}
.dim   { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* Subtle film grain on everything */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ════════════════════════════════════════════════════════════════════════
   LOGIN — radically minimal
   ──────────────────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--gutter-y) var(--gutter-x);
  position: relative;
  z-index: 10;
}

.login-corners {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.login-corner-l,
.login-corner-r {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--text-muted);
  animation: fade-in 700ms var(--ease) both;
}
.login-corner-r {
  text-align: right;
  animation-delay: 60ms;
}

@keyframes fade-in {
  0%   { opacity: 0; transform: translateY(-4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.login-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: clamp(60px, 10vh, 130px);
  width: 100%;
  margin: 0 auto;
  padding: clamp(40px, 10vh, 120px) 0;
}

.login-rule {
  margin: 0;
  height: 1px;
  width: 100%;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-strong) 8%,
    var(--border-strong) 92%,
    transparent 100%
  );
  animation: rule-grow 900ms var(--ease) both;
  transform-origin: center;
}
.login-rule + .login-content + .login-rule { animation-delay: 100ms; }
@keyframes rule-grow {
  0%   { transform: scaleX(0.4); opacity: 0; }
  100% { transform: scaleX(1); opacity: 1; }
}

.login-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(36px, 6vh, 64px);
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  animation: fade-up 900ms var(--ease) both;
  animation-delay: 200ms;
}
@keyframes fade-up {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

.login-title {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: clamp(40px, 8.5vw, 128px);
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--text);
  text-align: left;
}

/* Inline row : "mot de passe  ──────────────  →" */
.login-form-row {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 32px);
  width: 100%;
}

.login-label {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.login-input-wrap {
  flex: 1;
  position: relative;
  border-bottom: 1px solid var(--border-strong);
  transition: border-color var(--dur-base) var(--ease);
}
.login-input-wrap:focus-within {
  border-bottom-color: var(--text);
}

.login-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: clamp(16px, 1.6vw, 22px);
  letter-spacing: 0.10em;
  padding: 8px 0;
  caret-color: var(--accent);
}
.login-input::placeholder { color: var(--text-faint); }

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease),
              background var(--dur-base) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.login-submit:hover {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.login-submit:hover svg { transform: translateX(2px); }
.login-submit:active { transform: scale(0.95); }
.login-submit svg { transition: transform var(--dur-fast) var(--ease); }

.login-error {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--error);
  animation: shake 340ms var(--ease);
}
.login-error::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--error); box-shadow: 0 0 8px var(--error-glow);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* Login mobile */
@media (max-width: 540px) {
  .login-form-row {
    flex-wrap: wrap;
    row-gap: 12px;
  }
  .login-label { width: 100%; }
  .login-corner-l, .login-corner-r { font-size: 10px; }
}

/* ════════════════════════════════════════════════════════════════════════
   DASHBOARD — editorial sections
   ──────────────────────────────────────────────────────────────────────── */

.dash-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--gutter-y) var(--gutter-x);
  position: relative;
  z-index: 10;
}

/* Header row = brand left, status pill + clock + logout right */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: clamp(16px, 2.5vh, 28px);
}
.dash-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--text);
}
.dash-brand::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), 0 0 3px var(--accent);
  animation: brand-pulse 2400ms var(--ease) infinite;
}
.dash-brand-sep {
  color: var(--text-faint);
  margin: 0 2px;
}
.dash-brand-sub {
  color: var(--text-muted);
}
@keyframes brand-pulse {
  0%, 100% { box-shadow: 0 0 12px var(--accent-glow), 0 0 3px var(--accent); }
  50%      { box-shadow: 0 0 6px var(--accent-glow), 0 0 2px var(--accent); }
}
.dash-header-r {
  display: flex; align-items: center; gap: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: lowercase;
}
.dash-clock {
  color: var(--text-dim);
}
.dash-logout {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted);
  padding: 4px 0;
  transition: color var(--dur-fast) var(--ease);
}
.dash-logout:hover { color: var(--text); }
.dash-logout svg { width: 12px; height: 12px; }

/* Rule (shared with login) */
.dash-rule {
  margin: 0;
  height: 1px;
  width: 100%;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-strong) 4%,
    var(--border-strong) 96%,
    transparent 100%
  );
}

/* Section structure */
.dash-section {
  padding: clamp(22px, 3.5vh, 36px) 0;
}

.dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: clamp(14px, 2vh, 20px);
}
.dash-section-title {
  margin: 0;
  font-size: clamp(19px, 2.2vw, 26px);
  font-weight: 400;
  letter-spacing: -0.012em;
  line-height: 1.1;
  color: var(--text);
}
.dash-section-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.dash-section-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 8px;
}
.dash-section-meta .dot {
  width: 6px; height: 6px; border-radius: 50%;
}

/* Compact section variant — used for plumbing/internals */
.dash-section-compact {
  padding: clamp(16px, 2.5vh, 26px) 0;
}
.dash-section-compact .dash-section-head {
  padding-bottom: clamp(10px, 1.5vh, 16px);
}
.dash-section-compact .dash-section-title {
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--text-muted);
}

/* ─── METRICS — editorial readouts in a 4-column row ─── */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.metric {
  padding: clamp(14px, 1.6vw, 20px) clamp(14px, 1.5vw, 20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 108px;
}
.metric:last-child { border-right: 0; }

.metric-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.metric-value {
  font-family: var(--font-sans);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--text);
}
.metric-unit {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 300;
  letter-spacing: 0;
  margin-left: 3px;
}
.metric-bar {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
}
.metric-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  transition: width var(--dur-slow) var(--ease);
}
.fill-ok    { background: var(--ok);    box-shadow: 0 0 8px var(--ok-glow); }
.fill-warn  { background: var(--warn);  box-shadow: 0 0 8px var(--warn-glow); }
.fill-error { background: var(--error); box-shadow: 0 0 8px var(--error-glow); }

.metric-foot {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: auto;
}

@media (max-width: 900px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(1), .metric:nth-child(2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 540px) {
  .metric { min-height: 96px; padding: 14px 12px; }
  .metric-value { font-size: 22px; }
}

/* ─── SERVICES — glass tiles with corner screws ─── */

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(12px, 1.5vw, 18px);
}

.service-tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(18px, 2vw, 24px);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 160px;
  position: relative;
  text-decoration: none;
  color: inherit;
  transition: background var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease),
              transform var(--dur-base) var(--ease);
}
.service-tile .screw {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.30);
}
.service-tile .screw-tl { top: 8px; left: 8px; }
.service-tile .screw-tr { top: 8px; right: 8px; }
.service-tile .screw-bl { bottom: 8px; left: 8px; }
.service-tile .screw-br { bottom: 8px; right: 8px; }

a.service-tile { cursor: pointer; }
a.service-tile:hover {
  background: var(--glass-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
a.service-tile:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.service-tile.state-ok    { border-color: rgba(74, 222, 128, 0.20); }
.service-tile.state-ok .screw    { background: rgba(74, 222, 128, 0.60); }
.service-tile.state-warn  { border-color: rgba(251, 191, 36, 0.20); }
.service-tile.state-warn .screw  { background: rgba(251, 191, 36, 0.60); }
.service-tile.state-error { border-color: rgba(248, 113, 113, 0.22); }
.service-tile.state-error .screw { background: rgba(248, 113, 113, 0.60); }
.service-tile.is-soon { opacity: 0.42; }

.tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.tile-name {
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -0.015em;
  color: var(--text);
}
.tile-status {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.tile-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.tile-status .dot-ok    { background: var(--ok);    box-shadow: 0 0 8px var(--ok-glow); }
.tile-status .dot-warn  { background: var(--warn);  box-shadow: 0 0 8px var(--warn-glow); }
.tile-status .dot-error { background: var(--error); box-shadow: 0 0 8px var(--error-glow); }
.tile-status .dot-soon, .tile-status .dot-unknown { background: var(--down); }

.tile-desc {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  line-height: 1.5;
  text-transform: lowercase;
}

.tile-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: lowercase;
  color: var(--text-faint);
}
.tile-foot .tile-arrow {
  transition: transform var(--dur-fast) var(--ease), color var(--dur-fast);
}
a.service-tile:hover .tile-arrow {
  transform: translate(2px, -2px);
  color: var(--text);
}

/* ─── Internals strip — framed compact chips ─── */

.internals-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.internal-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--text-muted);
  position: relative;
}
/* Tiny screws to tie back to the service-tile visual language */
.internal-chip::before,
.internal-chip::after {
  content: "";
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}
.internal-chip::before { top: 4px; left: 4px; }
.internal-chip::after  { bottom: 4px; right: 4px; }

.internal-chip .dot {
  width: 5px; height: 5px; border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.internal-chip .dot-ok    { background: var(--ok);    box-shadow: 0 0 7px var(--ok-glow); }
.internal-chip .dot-warn  { background: var(--warn);  box-shadow: 0 0 7px var(--warn-glow); }
.internal-chip .dot-error { background: var(--error); box-shadow: 0 0 7px var(--error-glow); }
.internal-chip .dot-unknown { background: var(--down); }
.internal-chip .chip-name { color: var(--text); font-weight: 400; }
.internal-chip .chip-meta { color: var(--text-dim); }
.internal-chip .chip-sep  { color: var(--text-faint); margin: 0 2px; }

.internal-chip.state-ok    { border-color: rgba(74, 222, 128, 0.18); }
.internal-chip.state-warn  { border-color: rgba(251, 191, 36, 0.18); }
.internal-chip.state-error { border-color: rgba(248, 113, 113, 0.20); }

/* ─── Footer ─── */

.dash-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: clamp(20px, 3vh, 36px);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--text-dim);
}
.dash-footer a {
  color: var(--text-dim);
  transition: color var(--dur-fast);
}
.dash-footer a:hover { color: var(--text); }

@media (max-width: 720px) {
  .dash-header, .dash-footer { flex-direction: column; align-items: flex-start; gap: 16px; }
  .dash-header-r { flex-wrap: wrap; }
}

/* Status pill (small) for the header */
.health-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
}
.health-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.health-pill .dot-ok    { background: var(--ok);    box-shadow: 0 0 8px var(--ok-glow); }
.health-pill .dot-warn  { background: var(--warn);  box-shadow: 0 0 8px var(--warn-glow); }
.health-pill .dot-error { background: var(--error); box-shadow: 0 0 8px var(--error-glow); }

/* Pulse halo */
.pulse { position: relative; }
.pulse::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0;
  animation: pulse 2200ms var(--ease) infinite;
}
.dot-ok.pulse::after    { color: var(--ok); }
.dot-warn.pulse::after  { color: var(--warn); }
.dot-error.pulse::after { color: var(--error); }
@keyframes pulse {
  0%   { transform: scale(0.85); opacity: 0.65; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* HTMX feedback */
.htmx-swapping { opacity: 0; transition: opacity 90ms ease; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .login-rule, .login-content, .login-corner-l, .login-corner-r, .metric-bar-fill, .pulse::after {
    animation: none !important;
    transition: none !important;
  }
  a.service-tile:hover { transform: none; }
}
