/* item.css — one photo, video or note in detail (js/ui/item-screen.js).
 *
 * Phone held upright: the photo or video on top, the details (title, tags,
 * notes, voice notes, where and when) scrolling under it. While typing,
 * the photo shrinks so the note keeps room above the keyboard; a tap on
 * the photo gives it the whole screen. Wide screens, and phones on their
 * side: the picture on the left, the details on the right.
 * Only the tokens from app.css are used, so light and dark both work. The
 * picture area is always dark, like any photo viewer, so photos read well
 * in both themes.
 */

.item-screen { --item-media-h: clamp(220px, 46vh, 640px); }

.item-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.item-loading { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-muted); }
.item-gone { margin: auto; max-width: 440px; }
.item-gone > div:first-child { color: var(--text-faint); display: flex; justify-content: center; margin-bottom: 8px; }
.item-gone .btn { margin-top: 8px; }

/* ---- top bar ---------------------------------------------------------------- */

.item-nav { display: flex; align-items: center; gap: 2px; padding: 0 2px; }
.item-nav .icon-btn { min-width: 44px; height: 44px; padding: 0 8px; background: var(--surface-2); }
.item-nav .icon-btn:first-child { border-radius: var(--radius) 4px 4px var(--radius); }
.item-nav .icon-btn:last-child { border-radius: 4px var(--radius) var(--radius) 4px; }
.item-nav .icon-btn:active { background: var(--surface-3); }

/* ---- media area ------------------------------------------------------------- */

.item-media {
  position: relative;
  flex: none;
  height: var(--item-media-h);
  overflow: hidden;
  background: #0b0f14;
  color: #fff;
  transition: height 0.2s ease;
}
.item-screen.typing .item-media { height: clamp(110px, 22vh, 200px); }
.item-screen.immersive .item-media { flex: 1 1 auto; height: auto; }
.item-screen.immersive .item-details { display: none; }

.item-media-tools {
  position: absolute; z-index: 3;
  top: 10px; left: max(10px, var(--safe-left)); right: max(10px, var(--safe-right));
  display: flex; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
.item-media-tools > * { pointer-events: auto; }
.item-seg { background: rgba(0, 0, 0, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.item-seg button { min-height: 44px; padding: 0 16px; color: rgba(255, 255, 255, 0.88); }
.item-seg button.on { background: #fff; color: #111; }
.item-media-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.62); color: #fff;
  touch-action: manipulation;
}
.item-media-btn:active { background: rgba(0, 0, 0, 0.85); }
.item-media-spin { position: absolute; right: 14px; bottom: 14px; z-index: 3; pointer-events: none; }
.item-media-spin .spinner { width: 26px; height: 26px; border-width: 3px; border-color: rgba(255, 255, 255, 0.25); border-top-color: #fff; }

/* the zoomable photo */
.zv {
  position: absolute; inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: zoom-in;
  outline: none;
}
.zv.zoomed { cursor: grab; }
.zv.zoomed.gesturing { cursor: grabbing; }
.zv:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }
.zv-img {
  position: absolute; left: 0; top: 0;
  max-width: none;
  transform-origin: 0 0;
  pointer-events: none;
  -webkit-user-drag: none; user-select: none;
}
.zv.gesturing .zv-img { will-change: transform; }
.zv.animating .zv-img { transition: transform 0.22s ease-out; }
.zv-msg {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px;
  text-align: center; font-weight: 600;
  background: rgba(11, 15, 20, 0.8); color: #fff;
}
.zv-msg p { margin: 0; max-width: 420px; }
.zv-msg .btn { color: var(--text); }

/* video */
.item-video-wrap { position: absolute; inset: 0; touch-action: pan-y; }
.item-video { width: 100%; height: 100%; max-width: none; object-fit: contain; background: #000; }

/* note */
.item-screen.is-note .item-media,
.item-screen.is-note.typing .item-media {
  height: auto;
  background: var(--surface); color: var(--text);
  border-bottom: 1px solid var(--border);
}
.item-note-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 14px max(16px, var(--safe-right)) 14px max(16px, var(--safe-left));
  touch-action: pan-y;
}
.item-note-ic {
  width: 64px; height: 64px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: var(--warn-tint); color: var(--pin-note);
}
.item-note-k { font-size: 20px; font-weight: 750; }
.item-note-s { font-size: 14px; color: var(--text-muted); }

/* ---- details ------------------------------------------------------------------- */

.item-details {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 12px max(14px, var(--safe-right)) calc(32px + var(--safe-bottom)) max(14px, var(--safe-left));
}
.item-details > * { max-width: 720px; margin-left: auto; margin-right: auto; }

.item-banner { align-items: center; margin-bottom: 12px; }
.item-banner .btn { flex: none; }

.item-head { margin-top: 2px; }
.item-title {
  display: block; width: 100%;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font-size: 20px; font-weight: 750;
  outline: none;
}
.item-title::placeholder { color: var(--text-faint); font-weight: 600; }
.item-title:hover { border-color: var(--text-faint); }
.item-title:focus { border-style: solid; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-tint); }

.item-actions { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.item-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 64px; padding: 6px 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.item-action:active { background: var(--surface-2); transform: scale(0.98); }
.item-action:disabled { opacity: 0.45; pointer-events: none; }
.item-action.danger { color: var(--danger); }
.item-action.ok { color: var(--ok); }

.item-section { margin-top: 22px; }
.item-section-head { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0 2px 8px; }
.item-section-head h2 { flex: 1; font-size: 13px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.item-cap { margin: 8px 2px 0; font-size: 13px; color: var(--text-muted); }
.item-cap:empty { display: none; }

/* tags */
.item-tags { gap: 8px; }
.item-tag { min-height: 44px; padding: 0 14px; border-radius: 22px; font-size: 14.5px; touch-action: manipulation; }
.item-tag:active { transform: scale(0.97); }
.item-tag.pending { opacity: 0.7; }
.item-tag-add { border-style: dashed; color: var(--text-muted); background: transparent; }

/* notes */
.item-notes { min-height: 132px; resize: none; overflow: hidden; line-height: 1.45; }
.item-notes-bar { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; }
.item-dictate { flex: none; min-height: 44px; }
.item-dictate.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.item-live-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; animation: item-pulse 1.1s ease-in-out infinite; }
.item-interim { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-style: italic; color: var(--text-muted); }
.item-save { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 650; color: var(--text-muted); white-space: nowrap; }
.item-save.ok { color: var(--ok); }
.item-save-retry {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 40px; padding: 0 12px;
  border: 0; border-radius: 20px;
  background: var(--brand-tint); color: var(--danger);
  font-size: 13px; font-weight: 750;
}

/* voice notes */
.item-rec {
  display: flex; align-items: center; gap: 14px;
  padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.item-rec-btn {
  width: 64px; height: 64px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}
.item-rec-btn:active { background: var(--brand-dark); transform: scale(0.96); }
.item-rec-btn:disabled { opacity: 0.45; }
.item-rec.recording .item-rec-btn { animation: item-ring 1.4s ease-out infinite; }
.item-rec.busy .item-rec-btn { opacity: 0.7; }
.item-rec-info { flex: 1; min-width: 0; }
.item-rec-label { font-weight: 750; font-variant-numeric: tabular-nums; }
.item-rec.recording .item-rec-label { color: var(--brand); }
.item-rec-sub { font-size: 13px; color: var(--text-muted); }
.item-rec-meter { height: 8px; margin-top: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.item-rec-level { width: 100%; height: 100%; background: var(--ok); transform: scaleX(0.03); transform-origin: left center; transition: transform 0.08s linear; }

.item-unsaved { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.item-unsaved:empty { display: none; }
.item-unsaved-row { align-items: center; flex-wrap: wrap; }
.item-unsaved-t { font-weight: 700; }
.item-unsaved-btns { display: flex; gap: 6px; }

.item-voice-list { margin-top: 10px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.item-voice-empty { padding: 14px; font-size: 14px; color: var(--text-muted); }
.item-voice-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 4px 8px 10px; border-bottom: 1px solid var(--border); }
.item-voice-row:last-child { border-bottom: 0; }
.item-voice-play {
  width: 48px; height: 48px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  touch-action: manipulation;
}
.item-voice-row.playing .item-voice-play { background: var(--accent); border-color: var(--accent); color: #fff; }
.item-voice-t { font-weight: 700; }
.item-voice-s { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.item-voice-progress { height: 4px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--surface-3); }
.item-voice-progress > div { width: 100%; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left center; }
.item-voice-del { color: var(--text-muted); }

/* facts */
.item-card { padding: 2px 14px; }
.item-facts { margin: 0; }
.item-fact { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.item-fact:last-child { border-bottom: 0; }
.item-fact dt { flex: 0 0 104px; padding-top: 1px; font-size: 14px; color: var(--text-muted); }
.item-fact dd { flex: 1; min-width: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 600; overflow-wrap: anywhere; }
.item-fact-note { flex-basis: 100%; font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.item-pos, .item-heading, .item-gps { display: contents; }
.item-compass { display: inline-flex; color: var(--accent); }
.item-gps .mono { font-size: 14px; }
.item-link { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; font-weight: 700; text-decoration: none; }
.item-copy { min-height: 40px; }

/* the mini plan / map, and the video's path */
.item-mini-wrap { margin-top: 12px; }
.item-mini, .item-track {
  position: relative;
  height: 210px;
  overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}
.item-track { height: 260px; }
.item-mini-host { position: absolute; inset: 0; }
.item-mini-open { position: absolute; inset: 0; z-index: 5; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.item-mini-open:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--accent); }
.item-mini-hint {
  position: absolute; right: 8px; bottom: 8px; z-index: 6;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.62); color: #fff;
  font-size: 12px; font-weight: 700;
  pointer-events: none;
}
.item-mini-msg {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px;
  text-align: center; font-size: 14px; color: var(--text-muted);
}
.item-track-full { position: absolute; top: 8px; right: 8px; z-index: 6; }
.item-place-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.item-place-btns:empty { display: none; }

/* full-screen plan / map (open the plan, Move pin) */
.item-place { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
.item-place-view { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--surface-2); }
.item-place-bar .btn { flex: 1; max-width: 420px; }

@keyframes item-pulse { 50% { opacity: 0.25; } }
@keyframes item-ring {
  0% { box-shadow: 0 0 0 0 rgba(200, 55, 31, 0.55); }
  100% { box-shadow: 0 0 0 16px rgba(200, 55, 31, 0); }
}

/* ---- wide screens: picture left, details right ---------------------------------- */

@media (min-width: 900px) {
  .item-main { flex-direction: row; }
  .item-media,
  .item-screen.typing .item-media { flex: 1 1 auto; height: auto; }
  .item-details { flex: 0 0 440px; border-left: 1px solid var(--border); }
  .item-details > * { max-width: none; }
  /* A note has no picture: keep it one centred column. */
  .item-screen.is-note .item-main { flex-direction: column; }
  .item-screen.is-note .item-media { flex: none; }
  .item-screen.is-note .item-details { flex: 1 1 auto; border-left: 0; }
  .item-screen.is-note .item-details > * { max-width: 720px; }
}

/* a phone on its side */
@media (orientation: landscape) and (max-height: 540px) and (max-width: 899px) {
  .item-main { flex-direction: row; }
  .item-media,
  .item-screen.typing .item-media { flex: 1 1 55%; height: auto; }
  .item-details { flex: 1 1 45%; border-left: 1px solid var(--border); }
  .item-screen.is-note .item-main { flex-direction: column; }
  .item-screen.is-note .item-media { flex: none; }
  .item-screen.is-note .item-details { border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .item-media { transition: none; }
}
