/* Interactive introduction.
   The text itself inherits the site's body copy (style.css: Wremena Light, 16px, #333, justified),
   so the intro reads like the rest of the homepage. This file only styles what is new:
   clickable phrases, freshly revealed text, and the clip/photo card. */

#rayhan-intro { position: relative; }
#rayhan-intro .story { margin: 0 0 1.2em; }
#rayhan-intro .nowrap,
#rayhan-intro .inst { white-space: nowrap; }

/* Hidden until opened. The .ready class is added by a one-line script right after the markup,
   so without JavaScript the whole story is simply shown. */
#rayhan-intro.ready [data-more]:not(.is-open) { display: none; }
#rayhan-intro [hidden] { display: none !important; }

/* Phrases that open more: the site's link blue, no underline. */
#rayhan-intro [data-open] {
  color: #1c71ad;
  cursor: pointer;
  border-radius: 2px;
  transition: color .25s ease;
}
#rayhan-intro [data-open]:hover {
  color: #069;
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
#rayhan-intro [data-open]:focus-visible { outline: 2px solid #1c71ad; outline-offset: 2px; }
#rayhan-intro [data-open]:focus:not(:focus-visible) { outline: none; }

/* Once opened, a phrase becomes ordinary text, so only the next places to click stay blue.
   It can still be clicked to fold the story back; hovering shows that. */
#rayhan-intro [data-open][aria-expanded="true"] { color: inherit; }
#rayhan-intro strong [data-open][aria-expanded="true"] { color: #222; }
#rayhan-intro [data-open][aria-expanded="true"]:hover {
  color: #069;
  text-decoration-color: rgba(0, 102, 153, .45);
}

/* Ordinary links inside the story are underlined, so they read as "this leaves the page". */
#rayhan-intro .story a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(28, 113, 173, .35);
}
#rayhan-intro .story a:hover { text-decoration-color: currentColor; }

/* Newly revealed text fades in with a brief tint, so the eye finds what was added. */
@keyframes ri-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ri-tint { from { background-color: rgba(28, 113, 173, .13); } to { background-color: rgba(28, 113, 173, 0); } }
#rayhan-intro .arrive { animation: ri-fade .3s ease-out, ri-tint 1.6s ease-out; }

/* Longer threads open as their own paragraph; a second friend starts below the first. */
#rayhan-intro .para.is-open { display: block; margin-top: 1em; }
#rayhan-intro .friend-second { display: block; margin-top: 1em; }

/* Institution logos, same size and offset as the original homepage. */
#rayhan-intro .mark {
  display: inline-block;
  width: 18px; height: 18px; max-width: none;
  margin: 0 0 0 3px; padding: 0; border: 0; border-radius: 0; box-shadow: none;
  vertical-align: middle;
  transform: translateY(-8%);
}
#rayhan-intro .mark-michigan { width: 22px; }
#rayhan-intro .mark-chelsea { width: 20px; height: 20px; transform: translateY(-13%); }

/* Just one "+", on the first phrase, until the visitor opens something. */
#rayhan-intro .ri-hint { white-space: nowrap; }
#rayhan-intro .ri-hint::after {
  content: "";
  display: inline-block;
  width: .5em;
  height: .5em;
  margin-left: .22em;
  vertical-align: .1em;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat;
  opacity: .75;
  transition: transform .2s ease;
}
#rayhan-intro [data-open]:hover > .ri-hint::after { transform: rotate(90deg); }
#rayhan-intro.used .ri-hint::after,
#rayhan-intro [aria-expanded="true"] > .ri-hint::after { display: none; }

/* One-time underline sweep on the opening phrases (added by the script for first-time visitors):
   a thin line draws in under the phrase and slides away. */
@keyframes ri-sweep {
  0%   { background-size: 0 1px;    background-position: 0 100%; }
  50%  { background-size: 100% 1px; background-position: 0 100%; }
  50.1%{ background-size: 100% 1px; background-position: 100% 100%; }
  100% { background-size: 0 1px;    background-position: 100% 100%; }
}
#rayhan-intro .glint {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  animation: ri-sweep 1.3s ease-in-out;
}

/* Phrases that open a clip or photo carry a small mark (play triangle or picture)
   that never wraps away from the words. */
#rayhan-intro .media-tail { white-space: nowrap; }
#rayhan-intro [data-media$=".mp4"] .media-tail::after {
  content: "";
  display: inline-block;
  margin-left: .28em;
  border-left: .42em solid currentColor;
  border-top: .26em solid transparent;
  border-bottom: .26em solid transparent;
  vertical-align: .06em;
  opacity: .8;
}
#rayhan-intro [data-media]:not([data-media$=".mp4"]) .media-tail::after {
  content: "";
  display: inline-block;
  width: .95em;
  height: .8em;
  margin-left: .3em;
  vertical-align: -.02em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 13'><rect x='.75' y='.75' width='14.5' height='11.5' rx='2' fill='none' stroke='black' stroke-width='1.5'/><path d='M3 10.5l3.4-4 2.4 2.8 1.6-1.7 2.6 2.9z'/><circle cx='11.3' cy='4' r='1.3'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 13'><rect x='.75' y='.75' width='14.5' height='11.5' rx='2' fill='none' stroke='black' stroke-width='1.5'/><path d='M3 10.5l3.4-4 2.4 2.8 1.6-1.7 2.6 2.9z'/><circle cx='11.3' cy='4' r='1.3'/></svg>") center / contain no-repeat;
  opacity: .85;
}
#rayhan-intro [data-media][aria-expanded="true"] { color: #1c71ad; }

/* Clip/photo card in the style of the research cards, anchored to the phrase. */
#rayhan-intro .media-card {
  position: absolute;
  z-index: 30;
  display: block;
  width: 232px;
  padding: 8px;
  background: #fffff8;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .06);
  text-align: left;
  line-height: 1.2;
  animation: ri-fade .2s ease-out;
}
#rayhan-intro .media-card img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  margin: 0;
  border-radius: 8px;
  box-shadow: none;
}
#rayhan-intro .media-card video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  background: #1d2622;
  cursor: pointer;
}
#rayhan-intro .media-bar { display: flex; align-items: center; gap: 2px; padding: 6px 0 0 4px; }
#rayhan-intro .media-caption {
  flex: 1;
  font-family: "Crimson Pro", serif;
  font-weight: 600;
  font-size: 16px;
  color: #2c3e50;
  white-space: nowrap;
}
#rayhan-intro .media-bar button {
  min-width: 32px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1c71ad;
  font: 400 13px/1 Lato, Helvetica, Arial, sans-serif;
  cursor: pointer;
}
#rayhan-intro .media-bar button:hover { background: #f1f3f5; color: #069; }
#rayhan-intro .media-bar button:focus-visible { outline: 2px solid #1c71ad; outline-offset: 0; }
#rayhan-intro .media-close { font-size: 20px !important; color: #6c757d !important; }

/* Justified text leaves big gaps on narrow screens; read ragged-right there. */
@media (max-width: 600px) {
  #rayhan-intro .story { text-align: left; }
}

/* Bigger tap area on touch screens without changing the line spacing. */
@media (pointer: coarse) {
  #rayhan-intro [data-open] { padding: 6px 0; }
}

@media (prefers-reduced-motion: reduce) {
  #rayhan-intro .glint,
  #rayhan-intro .arrive,
  #rayhan-intro .media-card { animation: none; }
  #rayhan-intro [data-open] { transition: none; }
}
