/* ==========================================================================
   blog.css
   Page-level components for the reading room.
   Requires ../assets/desktop.css, which supplies color modes and chrome.
   ========================================================================== */

/* --- Desktop environment (index.html) --- */
.desktop-body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.desktop-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 16px;
  padding: 16px;
  overflow: auto;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #ffffff;
  text-decoration: none;
  font-size: 0.75rem;
  width: 84px;
  padding: 4px;
  cursor: pointer;
}
.desktop-icon:visited { color: #ffffff; }

.desktop-icon .icon-image {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}

.desktop-icon .icon-text {
  text-shadow: 1px 1px 1px #000;
  padding: 2px;
  word-wrap: break-word;
  width: 100%;
}

.desktop-icon:hover .icon-image,
.desktop-icon:focus-visible .icon-image { filter: brightness(1.2); }

.desktop-icon:hover .icon-text,
.desktop-icon:focus-visible .icon-text {
  background: rgba(0, 0, 128, 0.75);
  outline: 1px dotted rgba(255, 255, 255, 0.6);
}

[data-theme="contrast"] .desktop-icon .icon-text { text-shadow: none; background: #000000; }

/* --- Taskbar --- */
.taskbar {
  min-height: 34px;
  background: var(--window-face);
  border-top: 2px solid var(--bevel-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 2px;
  z-index: 9999;
  flex-wrap: wrap;
}

.start-btn {
  font-weight: bold;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
}

.taskbar-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.taskbar-controls button { padding: 2px 8px; }

.taskbar-tray {
  border: 1px solid var(--bevel-dark-soft);
  padding: 0 10px;
  min-height: 24px;
  display: flex;
  align-items: center;
  font-size: 0.6875rem;
}

.start-wrapper { position: relative; }

.start-tooltip,
.pagedoll-tooltip {
  display: none;
  position: absolute;
  background-color: #ffffe1;
  color: #000000;
  border: 1px solid #000000;
  padding: 4px 8px;
  font-size: 0.6875rem;
  white-space: nowrap;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
  z-index: 10000;
}
.start-tooltip { bottom: calc(100% + 4px); left: 0; }
.start-tooltip.show { display: block; }

/* --- Workspace and article --- */
.workspace {
  margin: 2px;
  background: var(--window-content-bg);
  padding: 24px;
  overflow-y: auto;
}

.scholarly-article {
  font-family: "Times New Roman", Times, serif;
  font-size: calc(1.125rem * var(--text-scale));
  line-height: 1.65;
  max-width: 72ch;
  margin: 0 auto;
  color: var(--text-color);
}
.scholarly-article a { color: var(--link-color); }

.article-header {
  border-bottom: 2px solid var(--text-color);
  margin-bottom: 24px;
  padding-bottom: 12px;
}
.article-title { font-size: 2.2em; margin: 0 0 8px 0; line-height: 1.1; }
.article-subtitle { font-size: 1.4em; font-style: italic; font-weight: normal; margin: 0 0 16px 0; }
.article-meta {
  font-family: "Tahoma", sans-serif;
  font-size: calc(0.8125rem * var(--text-scale));
  color: var(--text-secondary);
}

/* Group boxes sit on the white workspace, so the legend matches it */
.workspace .groupbox {
  margin: 24px 0;
  padding: 16px;
  font-family: "Tahoma", sans-serif;
  font-size: calc(0.8125rem * var(--text-scale));
}
.workspace .groupbox-legend {
  left: 12px;
  background: var(--window-content-bg);
  font-size: calc(0.75rem * var(--text-scale));
}
.abstract-box { font-style: italic; }
.reference-list { margin: 0; padding-left: 20px; }
.reference-list li { margin-bottom: 8px; }

/* --- Alert banner --- */
.alert-banner {
  background: var(--window-face);
  font-family: "Tahoma", sans-serif;
  font-size: calc(0.8125rem * var(--text-scale));
  border: 2px solid;
  border-top-color: var(--bevel-light);
  border-left-color: var(--bevel-light);
  border-right-color: var(--bevel-dark-soft);
  border-bottom-color: var(--bevel-dark-soft);
  margin-bottom: 24px;
  box-shadow: inset 1px 1px 0 var(--bevel-light-soft), inset -1px -1px 0 var(--bevel-dark);
}
.alert-summary {
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  font-weight: bold;
  background: var(--window-face);
  list-style: none;
  user-select: none;
}
.alert-summary::-webkit-details-marker { display: none; }
.alert-summary:focus-visible { outline: var(--focus-outline); outline-offset: -3px; }
.alert-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  background: var(--highlight-bg);
  color: var(--highlight-fg);
  text-align: center;
  font-size: 1.125rem;
  font-style: italic;
  margin-right: 12px;
}
.alert-content { padding: 8px 12px 12px 48px; border-top: 1px solid var(--bevel-dark-soft); }

/* --- Inline citations --- */
.cite-btn {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0 2px;
  color: var(--link-color);
  text-decoration: underline;
  font-family: inherit;
  font-size: 0.85em;
  vertical-align: super;
  cursor: pointer;
  display: inline;
  min-width: 0;
  min-height: 0;
  height: auto;
}
.cite-btn:hover { background: var(--highlight-bg); color: var(--highlight-fg); text-decoration: none; }

/* --- Media player --- */
.retro-media-player { background: var(--window-face); display: flex; flex-direction: column; gap: 8px; }
.media-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.media-btn { min-width: 56px; }
.media-seek {
  flex: 1;
  min-width: 120px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px solid var(--bevel-dark-soft);
  height: 20px;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
}
.media-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 10px;
  background: var(--window-face);
  border: 1px solid var(--bevel-dark-soft);
  cursor: pointer;
}
.media-seek::-moz-range-thumb {
  height: 16px;
  width: 10px;
  border-radius: 0;
  background: var(--window-face);
  border: 1px solid var(--bevel-dark-soft);
  cursor: pointer;
}
.media-time {
  background: #000000;
  color: #00ff00;
  font-family: "Courier New", monospace;
  padding: 2px 6px;
  font-size: 0.75rem;
  border: 1px solid var(--bevel-dark-soft);
}
[data-theme="contrast"] .media-time { background: #000000; color: #ffffff; }
.media-status { font-size: 0.6875rem; color: var(--text-secondary); }
.transcript-drawer summary { cursor: pointer; font-weight: bold; margin-top: 8px; }
.transcript-content {
  background: var(--window-content-bg);
  color: var(--text-color);
  padding: 8px;
  border: 1px solid var(--bevel-dark-soft);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}

/* --- Figures --- */
.retro-figure { margin: 32px 0; text-align: center; }
.figure-frame {
  display: inline-block;
  position: relative;
  background: var(--window-face);
  padding: 8px;
  border: 2px solid;
  border-top-color: var(--bevel-light);
  border-left-color: var(--bevel-light);
  border-right-color: var(--bevel-dark-soft);
  border-bottom-color: var(--bevel-dark-soft);
}
.figure-frame img { max-width: 100%; height: auto; display: block; border: 1px solid var(--bevel-dark); }
.figure-caption {
  font-family: "Tahoma", sans-serif;
  font-size: calc(0.75rem * var(--text-scale));
  color: var(--text-secondary);
  margin: 8px auto 0 auto;
  max-width: 60ch;
}
/* The zoom button stays present for keyboard and touch users, and is only
   less prominent until the figure is hovered or the button is focused. */
.lightbox-trigger {
  position: absolute;
  bottom: 16px;
  right: 16px;
  opacity: 0.4;
  transition: opacity 0.2s;
  padding: 2px 8px;
}
.figure-frame:hover .lightbox-trigger,
.lightbox-trigger:focus-visible { opacity: 1; }

/* --- Image viewer --- */
.lightbox-dialog {
  width: 80vw;
  max-width: 900px;
  height: 80vh;
  max-height: 80vh;
  top: 10vh;
  left: 10vw;
  transform: none;
}
.lightbox-workspace { flex: 1; display: flex; overflow: hidden; background: var(--bevel-dark-soft); margin: 2px; }
.lightbox-image-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.lightbox-image-container img { max-width: 100%; max-height: 100%; transition: transform 0.2s; object-fit: contain; }
.lightbox-metadata {
  width: 250px;
  background: var(--window-face);
  padding: 12px;
  display: none;
  border-left: 2px solid var(--bevel-light);
  overflow-y: auto;
}
.lightbox-metadata.show { display: block; }
.lightbox-metadata dt { font-weight: bold; margin-top: 8px; }
.lightbox-metadata dd { margin: 0 0 4px 0; color: var(--text-secondary); }
.lightbox-toolbar {
  background: var(--window-face);
  padding: 6px;
  display: flex;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--bevel-light);
  margin: 0 2px 2px 2px;
  flex-wrap: wrap;
}

/* --- Pagedoll --- */
.pagedoll {
  position: fixed;
  z-index: 900;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.3));
  cursor: pointer;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  min-height: 0;
  min-width: 0;
}
.pagedoll[data-position="bottom-right"] { bottom: 60px; right: 40px; }
.pagedoll-sprite { display: block; font-size: 3rem; animation: floatIdle 3s ease-in-out infinite; }
.pagedoll-tooltip { bottom: 85%; left: 50%; transform: translateX(-50%); pointer-events: none; }
.pagedoll-tooltip.show { display: block; }
.pagedoll.shaking .pagedoll-sprite { animation: pagedollShake 0.4s ease-in-out; }

@keyframes floatIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pagedollShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20%, 60% { transform: translateX(-6px) rotate(-12deg); }
  40%, 80% { transform: translateX(6px) rotate(12deg); }
}

/* --- Small screens --- */
@media (max-width: 720px) {
  .workspace { padding: 14px; }
  .lightbox-dialog { width: 96vw; left: 2vw; height: 90vh; max-height: 90vh; top: 5vh; }
  .lightbox-metadata { width: 140px; }
  .pagedoll[data-position="bottom-right"] { bottom: 16px; right: 16px; }
  .desktop-grid { flex-direction: row; }
}

/* --- Print --- */
@media print {
  .pagedoll, .skip-link, .lightbox-trigger, .taskbar { display: none !important; }
  .workspace { padding: 0; overflow: visible; }
  .scholarly-article { max-width: none; }
}

/* --- Embedded PDF viewer (presentations) --- */
.pdf-workspace {
  padding: 0;
  height: 78vh;
  min-height: 320px;
  display: flex;
}
.pdf-embed { flex: 1; width: 100%; border: 0; }
.pdf-fallback {
  padding: 32px 24px;
  max-width: 60ch;
  margin: 0 auto;
  font-size: calc(1rem * var(--text-scale));
  color: var(--text-color);
}
.pdf-fallback h1 { font-size: 1.5rem; margin-top: 0; }

@media (max-width: 720px) {
  .pdf-workspace { height: auto; min-height: 0; }
}
