/* ==========================================================================
   expand.css — clamped cards, expand-on-click dialog, zoomable graphics
   Pairs with expand.js. Theme via the custom properties below.
   ========================================================================== */

:root {
  --xp-bg:        #05100b;   /* dialog / page ground   */
  --xp-panel:     #0f2118;   /* card + dialog surface  */
  --xp-stroke:    #1f4433;   /* borders                */
  --xp-text:      #d8f3e4;   /* body text              */
  --xp-muted:     #7fae97;   /* secondary text         */
  --xp-accent:    #4ade80;   /* links, focus, controls */
  --xp-accent-hi: #86efac;   /* hover                  */
  --xp-lines:     4;         /* clamped lines in a card */
}

/* --------------------------------------------------------------------------
   1. Cards — contain the text, never let it escape
   -------------------------------------------------------------------------- */

.projects-box,
.experience-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.project-card,
.experience-box {
  /* grid + flex children default to min-width:auto and refuse to shrink.
     Without this the CARD overflows, and no amount of text wrapping helps. */
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--xp-panel);
  border: 1px solid var(--xp-stroke);
  border-radius: 14px;
  position: relative;
}

.project-card :is(h3, h4, p),
.experience-box :is(h3, h4, p) {
  min-width: 0;
  overflow-wrap: break-word;   /* break only words that cannot fit */
  hyphens: auto;
}

/* Clamp the body copy to a fixed number of lines so cards stay level. */
.card-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--xp-lines);
  line-clamp: var(--xp-lines);
  overflow: hidden;
  margin: 0 0 1rem;
  color: var(--xp-muted);
  flex: 1 1 auto;
}

/* Media keeps the SVG aspect ratio, so nothing letterboxes or crops. */
.card-media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--xp-bg);
  cursor: zoom-in;
}

.card-body { padding: 1.25rem; display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.card-body > .btn { margin-top: auto; align-self: flex-start; }

/* --------------------------------------------------------------------------
   2. The "Read more" affordance — only shown when text is actually cut off.
      expand.js sets data-clamped="true" after measuring.
   -------------------------------------------------------------------------- */

.card-expand {
  display: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--xp-accent);
  cursor: pointer;
  align-self: flex-start;
}
.card-expand:hover { color: var(--xp-accent-hi); text-decoration: underline; }
[data-clamped="true"] .card-expand { display: inline-block; }

/* Whole card is clickable only when there is more to read. */
[data-clamped="true"] { cursor: pointer; }

:is(.project-card, .experience-box):focus-visible,
.card-expand:focus-visible,
.card-media:focus-visible {
  outline: 2px solid var(--xp-accent);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   3. Dialogs
   -------------------------------------------------------------------------- */

.xp-dialog {
  border: 1px solid var(--xp-stroke);
  border-radius: 16px;
  background: var(--xp-panel);
  color: var(--xp-text);
  padding: 0;
  max-width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
  overscroll-behavior: contain;
}
.xp-dialog::backdrop { background: rgb(0 0 0 / 0.72); backdrop-filter: blur(3px); }

.xp-dialog__close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  background: var(--xp-panel);
  border: 1px solid var(--xp-stroke);
  color: var(--xp-muted);
  border-radius: 8px;
  width: 34px; height: 34px;
  font-size: 18px; line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.xp-dialog__close:hover { color: var(--xp-text); border-color: var(--xp-accent); }

.xp-dialog__content { padding: 0 1.75rem 1.75rem; }
.xp-dialog__content img { width: 100%; aspect-ratio: 16/9; object-fit: contain; background: var(--xp-bg); border-radius: 10px; cursor: zoom-in; }
.xp-dialog__content h3 { margin: 1.25rem 0 0.5rem; }
/* full text in the dialog — clamp removed */
.xp-dialog__content .card-text {
  display: block; -webkit-line-clamp: none; line-clamp: none;
  overflow: visible; color: var(--xp-text); line-height: 1.65;
}
.xp-dialog__content .card-expand { display: none !important; }

/* --------------------------------------------------------------------------
   4. Zoom viewer
   -------------------------------------------------------------------------- */

.xp-zoom {
  border: 0;
  padding: 0;
  width: 96vw;
  height: 92vh;
  max-width: 96vw;
  max-height: 92vh;
  background: var(--xp-bg);
  border-radius: 14px;
  overflow: hidden;
}
.xp-zoom::backdrop { background: rgb(0 0 0 / 0.88); }

.xp-zoom__stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;           /* we handle pan + pinch ourselves */
}
.xp-zoom__stage.is-panning { cursor: grabbing; }

.xp-zoom__img {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  max-width: none;              /* transform controls size, not CSS */
}

.xp-zoom__bar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgb(5 16 11 / 0.9);
  border: 1px solid var(--xp-stroke);
  border-radius: 10px;
  z-index: 2;
}
.xp-zoom__bar button {
  min-width: 38px; height: 34px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--xp-muted);
  font: inherit; font-size: 15px;
  cursor: pointer;
}
.xp-zoom__bar button:hover { color: var(--xp-text); border-color: var(--xp-stroke); }
.xp-zoom__bar button:focus-visible { outline: 2px solid var(--xp-accent); outline-offset: 2px; }
.xp-zoom__level { min-width: 56px; display: grid; place-items: center; color: var(--xp-muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.xp-zoom__hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  color: var(--xp-muted); font-size: 12.5px; z-index: 2;
  background: rgb(5 16 11 / 0.85); padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--xp-stroke);
  transition: opacity .4s ease;
}
.xp-zoom__hint[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .xp-zoom__img { transition: none !important; }
}
