/* =============================================================================
   PHOTOLOG DOWNLOADS — hover button, strip button, dialogs
   =============================================================================
   Loaded by BOTH public shells when the project offers downloads, next to
   photolog_group.css and for the same reason: Journal loads neither
   project.css nor Bootstrap, so anything downloads need lives here.

   Everything is deliberately layout-agnostic. These elements appear over
   three very different page designs (simple, essay-01, journal) and must
   read as chrome that belongs to the photograph, not to any one layout:
   near-black circles on the image (the lightbox's visual family), and plain
   neutral dialogs.
   ========================================================================== */

/* --- the per-image hover button ------------------------------------------
   Injected by photolog_download.js into each image's parent, which gets
   .pf-dl-host. Port of lrgallery's .lrgc-dl-btn recipe: quiet until the
   photograph is approached, revealed on hover AND :focus-within (keyboard),
   always visible where hover does not exist (touch). */
:root {
  /* The editor's motion curve (--pfe-ease in editor_form.css), restated
     because the public pages do not load the editor's token block. One
     deceleration curve across the product, whichever side of the login. */
  --pf-dl-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.pf-dl-host {
  position: relative;
}

.pf-dl-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  /* Solid enough that a white glyph stays legible over a bright sky — the
     disc is the contrast, not the photograph underneath it. Reveal is carried
     by opacity, so this alpha is what remains once revealed. */
  background: rgba(17, 17, 17, 0.72);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 140ms var(--pf-dl-ease),
              transform 140ms var(--pf-dl-ease),
              background-color 140ms var(--pf-dl-ease);
}

.pf-dl-host:hover .pf-dl-btn,
.pf-dl-host:focus-within .pf-dl-btn {
  opacity: 1;
  transform: scale(1);
}

.pf-dl-btn:hover,
.pf-dl-btn:focus-visible {
  background: rgba(0, 0, 0, 0.88);
}

.pf-dl-btn:active {
  transform: scale(0.92);
  background: #000;
}

.pf-dl-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* No hover, no reveal moment — the button simply is there, and it grows to
   the 44px the house rule gives every icon-only control on touch. */
@media (hover: none) {
  .pf-dl-btn {
    width: 2.75rem;
    height: 2.75rem;
    opacity: 1;
    transform: none;
  }
  .pf-dl-btn:active { transform: scale(0.94); }
}

/* In the lightbox the button joins the fixed chrome instead of an image
   corner; the lightbox's own controls are plain glyphs, so a filled circle
   holds its own against the dark backdrop. */
.pf-dl-btn--lightbox {
  position: absolute;
  top: 1rem;
  left: 1rem;
  opacity: 1;
  transform: none;
}

/* --- the strip's download-all button --------------------------------------
   Nothing to add: .pf-strip__item (project.css / journal.css) already carries
   the pill, the icon gap and the type. Likes and comments put a count in that
   last slot; a download has nothing to count, so the word goes there instead
   and inherits everything. */

/* --- dialogs ---------------------------------------------------------------
   Native <dialog>: the platform provides the top layer, the backdrop, the
   focus trap and Escape — no z-index negotiation with three layouts, and no
   modal framework on a page that has none. Quiet, neutral surfaces so they
   sit over all three layouts without borrowing any one's voice. */
.pf-dl-dialog {
  width: min(26rem, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  color: #1d1f21;
}

.pf-dl-dialog::backdrop {
  background: rgba(10, 10, 12, 0.55);
}

/* Entrance only, and only as an enhancement: the dialog is fully visible
   from its first frame, so a browser that skips the animation still shows
   a correct dialog. */
.pf-dl-dialog[open] {
  animation: pf-dl-appear 160ms var(--pf-dl-ease);
}

@keyframes pf-dl-appear {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
}

.pf-dl-dialog__body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
  padding: 1.4rem 1.5rem 1.25rem;
}

.pf-dl-dialog__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.pf-dl-dialog__text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #444;
}

.pf-dl-dialog__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
}

.pf-dl-dialog__input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid #9aa0a6;
  border-radius: 7px;
  font: inherit;
  font-size: 0.95rem;
  color: #1d1f21;
  background: #fff;
}

/* Placeholders are read, so they clear 4.5:1 like body text — the usual
   near-invisible gray is a legibility bug, not a style. */
.pf-dl-dialog__input::placeholder {
  color: #6b7280;
  opacity: 1;
}

.pf-dl-dialog__input:focus-visible {
  outline: 2px solid #1d1f21;
  outline-offset: 1px;
}

/* A field the server just rejected says so in its own border, not only in
   the sentence underneath it. */
.pf-dl-dialog__input[aria-invalid="true"] {
  border-color: #b3261e;
}

.pf-dl-dialog__input--pin {
  max-width: 7.5rem;
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 0.45em;
  /* Compensate the tracking after the last digit so 4 digits sit centred. */
  padding-left: calc(0.7rem + 0.45em);
}

.pf-dl-dialog__error {
  margin: 0;
  font-size: 0.85rem;
  color: #b3261e;
}

.pf-dl-dialog__note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #6b7280;
}

.pf-dl-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.pf-dl-dialog__cancel,
.pf-dl-dialog__confirm {
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.pf-dl-dialog__cancel {
  border: 1px solid #9aa0a6;
  background: #fff;
  color: #3c4043;
}

.pf-dl-dialog__cancel:hover { background: #f3f4f5; }
.pf-dl-dialog__cancel:active { background: #e8eaed; }

.pf-dl-dialog__confirm {
  border: 1px solid #1d1f21;
  background: #1d1f21;
  color: #fff;
}

.pf-dl-dialog__confirm:hover { background: #000; }
.pf-dl-dialog__confirm:active { background: #000; transform: translateY(1px); }

/* While the unlock request is in flight: no second submit, and the button
   says it is working rather than looking merely dead. */
.pf-dl-dialog__confirm[disabled],
.pf-dl-dialog__cancel[disabled] {
  opacity: 0.6;
  cursor: default;
}

.pf-dl-dialog__cancel:focus-visible,
.pf-dl-dialog__confirm:focus-visible,
.pf-dl-size:focus-visible {
  outline: 2px solid #1d1f21;
  outline-offset: 2px;
}

/* Size chooser: each size is one full-width row — a choice, not a form. */
.pf-dl-sizes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pf-dl-size {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  /* ≥44px tall: this is the one control on a phone that decides the download. */
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid #9aa0a6;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms var(--pf-dl-ease),
              background-color 140ms var(--pf-dl-ease);
}

.pf-dl-size:hover {
  border-color: #1d1f21;
  background: #fafafa;
}

.pf-dl-size:active { background: #f1f2f3; }

.pf-dl-size__name {
  font-size: 0.95rem;
  font-weight: 600;
}

.pf-dl-size__hint {
  font-size: 0.8rem;
  color: #6b7280;
}

/* The size dialog's lone cancel (direct child of the column body); the
   two-button dialogs align through __actions instead. */
.pf-dl-dialog__body > .pf-dl-dialog__cancel { align-self: flex-end; }

/* --- small photographs -----------------------------------------------------
   A collage tile is a fraction of a row wide at EVERY viewport, so this is a
   property of the host, not of the screen — but it is addressed by class, not
   by a container query.

   ⚠ This was `container-type: inline-size` on .pf-dl-host until 2026-08-25,
   and it broke the Journal layout in production: size containment makes an
   element's inline size resolve WITHOUT its contents, and .pf-essay__media
   then collapsed to an intrinsic default (1280px photos rendered at 768, some
   at 320). Carousel slides and the Essay preset were unaffected, which is
   exactly why a narrow test missed it. Never put containment on a host whose
   width the layout derives from what is inside it. */
.pf-group-item .pf-dl-btn {
  width: 2rem;
  height: 2rem;
  top: 0.3rem;
  right: 0.3rem;
}
.pf-group-item .pf-dl-btn svg {
  width: 15px;
  height: 15px;
}

/* Touch has no hover, so on a collage tile the button would sit there
   permanently covering a third of the picture. Drop it: the photograph itself
   is a generous tap target, it opens the lightbox, and the lightbox carries
   its own full-size download button. Nothing becomes unreachable. */
@media (hover: none) {
  .pf-group-item .pf-dl-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pf-dl-btn,
  .pf-dl-size,
  .pf-dl-dialog__cancel,
  .pf-dl-dialog__confirm {
    transition: none;
  }
  .pf-dl-btn:active,
  .pf-dl-dialog__confirm:active { transform: none; }
  .pf-dl-dialog[open] { animation: none; }
}
