/* flowmap.css — Flow Map page styles */

/* --- Layout --- */
.flowmap-page {
  padding: var(--space-xl) 0 var(--space-2xl);
}

.flowmap-header {
  text-align: center;
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
}

.flowmap-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: var(--space-sm);
}

.flowmap-header p {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--sepia);
  font-size: 1.05rem;
  margin: 0;
}

/* --- Phase Groups --- */
.phase-label {
  font-family: var(--font-stamp);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 4px 14px;
  border: 1px dashed;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: var(--space-md);
}

.phase-pre  { color: var(--saffron);      border-color: var(--saffron); }
.phase-day  { color: var(--india-green);  border-color: var(--india-green); }
.phase-post { color: var(--navy);         border-color: var(--navy); }

/* --- Flowchart Container (Desktop: horizontal) --- */
.flowchart {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
  overflow-x: auto;
}

.phase-group {
  margin-bottom: var(--space-xl);
  position: relative;
}

.phase-group-header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.nodes-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  position: relative;
}

/* Connector between nodes */
.node-connector {
  flex-shrink: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 60px; /* align with middle of node card */
}

.node-connector::after {
  content: '';
  display: block;
  width: 100%;
  height: 0;
  border-top: 2px dashed var(--sepia-light);
}

/* Connector between phases (vertical arrow) */
.phase-connector {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: var(--space-sm) 0;
  color: var(--sepia-light);
  font-size: 1.2rem;
  font-family: var(--font-stamp);
}

/* --- Node Card --- */
.node-card {
  background: var(--khadi);
  border: 2px solid var(--sepia);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-md);
  width: 170px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  box-shadow: var(--shadow-sm);
  /* Ruled-line texture */
  background-image: repeating-linear-gradient(
    transparent, transparent 27px,
    rgba(123, 94, 58, 0.06) 28px
  );
}

.node-card:hover,
.node-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.node-card:focus-visible {
  outline: 2px solid var(--saffron);
  outline-offset: 3px;
}

/* Phase-based border colors */
.node-card.phase-pre  { border-color: var(--saffron);      box-shadow: 0 2px 8px rgba(224,123,57,0.15); }
.node-card.phase-day  { border-color: var(--india-green);  box-shadow: 0 2px 8px rgba(45,106,79,0.15); }
.node-card.phase-post { border-color: var(--navy);         box-shadow: 0 2px 8px rgba(26,26,46,0.15); }

.node-number {
  font-family: var(--font-stamp);
  font-size: 1.5rem;
  color: var(--sepia);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.node-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-sm);
  display: block;
}

.node-name {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  text-align: center;
  margin-bottom: var(--space-xs);
  line-height: 1.3;
}

.node-desc {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--ash);
  text-align: center;
  line-height: 1.4;
  margin: 0;
}

/* Completed stamp on node */
.node-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: none;
}

.node-card.completed .node-check {
  display: block;
  animation: stampIn 200ms ease-out;
}

/* --- Side Panel (Dossier) --- */
.side-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: min(480px, 100vw);
  height: calc(100vh - var(--header-h));
  background: var(--khadi);
  border-left: 2px solid var(--sepia);
  z-index: var(--z-panel);
  transform: translateX(100%);
  transition: transform 300ms ease;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  /* Ruled-line inner texture */
  background-image: repeating-linear-gradient(
    transparent, transparent 31px,
    rgba(123, 94, 58, 0.07) 32px
  );
}

.side-panel.open {
  transform: translateX(0);
}

/* Dossier tab at top */
.panel-tab {
  background: var(--sepia);
  color: var(--khadi);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1;
}

.panel-tab-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--khadi);
}

.panel-close {
  background: none;
  border: none;
  color: var(--khadi);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-close:hover { background: rgba(255,255,255,0.15); }

.panel-body {
  padding: var(--space-xl);
}

/* Stamp-style header inside panel */
.panel-stamp-header {
  border: 2px dashed var(--sepia);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  position: relative;
  border-radius: var(--radius-sm);
}

.panel-stage-num {
  font-family: var(--font-stamp);
  font-size: 2.5rem;
  color: var(--sepia-light);
  line-height: 1;
}

.panel-stage-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  margin-top: var(--space-xs);
}

.panel-timeline {
  display: inline-block;
  font-family: var(--font-stamp);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--sepia);
  background: rgba(224,123,57,0.08);
  border: 1px solid rgba(224,123,57,0.3);
  padding: 3px 10px;
  border-radius: 20px;
  margin-top: var(--space-sm);
}

.panel-content p {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--navy);
  line-height: 1.8;
  margin-bottom: var(--space-md);
}

/* Ask Gemini rubber stamp button */
.btn-ask-gemini {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--ballot-red);
  color: var(--white);
  border: none;
  font-family: var(--font-stamp);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  padding: 10px var(--space-lg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-transform: uppercase;
  transition: all var(--transition-fast);
  min-height: 44px;
  /* Rubber stamp feel */
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}
.btn-ask-gemini:hover {
  background: #a93226;
  transform: translateY(1px);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.2);
}

/* --- Gemini Chat Panel --- */
.chat-section {
  margin-top: var(--space-xl);
  border-top: 1px dashed var(--sepia);
  padding-top: var(--space-lg);
  display: none;
}
.chat-section.open { display: block; }

.chat-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
  padding-right: var(--space-xs);
}

.chat-msg {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
}

.chat-msg.user {
  background: rgba(224,123,57,0.1);
  border-left: 3px solid var(--saffron);
  color: var(--navy);
  align-self: flex-end;
  max-width: 90%;
}

.chat-msg.gemini {
  background: rgba(26,26,46,0.05);
  border-left: 3px solid var(--navy);
  color: var(--navy);
}

.chat-msg.error { background: var(--ballot-red-light); border-left: 3px solid var(--ballot-red); color: var(--ballot-red); }

.chat-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

/* Handwritten form field style — bottom border only */
.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--sepia);
  padding: var(--space-sm) 0;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--navy);
  outline: none;
  border-radius: 0;
  min-height: 44px;
}
.chat-input::placeholder { color: var(--sepia-light); font-style: italic; }
.chat-input:focus { border-bottom-color: var(--saffron); }

.chat-submit {
  background: var(--saffron);
  color: var(--white);
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 44px;
  min-height: 44px;
  transition: background var(--transition-fast);
}
.chat-submit:hover { background: var(--saffron-dark); }
.chat-submit:disabled { background: var(--ash); cursor: not-allowed; }

/* Panel overlay (backdrop) */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,0.3);
  z-index: calc(var(--z-panel) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
.panel-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* --- Mobile: vertical stacked flow --- */
@media (max-width: 900px) {
  .nodes-row { flex-direction: column; align-items: center; }
  .node-connector { width: 2px; height: 32px; padding: 0; }
  .node-connector::after {
    width: 0;
    height: 100%;
    border-top: none;
    border-left: 2px dashed var(--sepia-light);
  }
  .node-card { width: 100%; max-width: 340px; }
  .side-panel { width: 100vw; }
  .flowchart { padding: 0 var(--space-md); }
}
