/* =========================================================
   Jose Arellano Martorellet: site styles
   ---------------------------------------------------------
   To change the color scheme, edit the variables in :root.
   Everything else on the site reads from them.
   ========================================================= */

:root {
  --paper:   #fbfcfc;  /* page background */
  --ink:     #1b2330;  /* main text */
  --muted:   #586474;  /* secondary text: venues, dates */
  --accent:  #0e6b66;  /* links, highlights (deep teal) */
  --accent-soft: #e6f1ef; /* light tint behind small highlights */
  --rule:    #dfe5e8;  /* thin divider lines */

  /* Research-theme colors (dots on the home page) */
  --amber:   #df9a2b;
  --teal:    #1f8a80;
  --coral:   #d65f4b;
  --amber-soft: #f1c879; /* small dot behind the photo */

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --measure: 60rem;    /* max width of the content area (60rem = 960px) */
  --text:    48rem;    /* max width of paragraphs, so lines stay readable */
}

/* Dark mode.
   By default the site follows the visitor's device setting. The moon/sun button
   in the header overrides it by setting data-theme="light" or "dark" on <html>.
   If you change a dark color, change it in BOTH blocks below. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #12171d;
    --ink:     #e4e8ec;
    --muted:   #9aa6b2;
    --accent:  #6cc5bc;
    --accent-soft: #1b2b2d;
    --rule:    #2a333c;
    --amber:   #e8ae4f;
    --teal:    #4fb8ac;
    --coral:   #e57c69;
    --amber-soft: #8a6a2c;
  }
}
:root[data-theme="dark"] {
  --paper:   #12171d;
  --ink:   #e4e8ec;
  --muted:   #9aa6b2;
  --accent:  #6cc5bc;
  --accent-soft: #1b2b2d;
  --rule:  #2a333c;
  --amber:   #e8ae4f;
  --teal:  #4fb8ac;
  --coral:   #e57c69;
  --amber-soft: #8a6a2c;
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}

p { margin: 0 0 1em; }

.wrap {
  max-width: calc(var(--measure) + 4rem);
  margin: 0 auto;
  padding: 0 2rem;   /* side space on large screens; smaller on phones (see bottom) */
}

/* ---------- Header & navigation ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.site-name {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.site-name:hover { color: var(--accent); }

/* Name + light/dark button, kept together on the left of the header */
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.theme-toggle:hover { color: var(--ink); background: var(--accent-soft); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
/* Show the moon in light mode (click for dark) and the sun in dark mode */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.site-nav ul {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

main { padding: 3.5rem 0 4rem; }

/* ---------- Home page ---------- */

.hero {
  display: grid;
  grid-template-columns: 1fr 19rem;
  gap: 3.5rem;
  align-items: end;
}
.hero-text { padding-bottom: 3rem; }

.hero h1 {
  font-size: clamp(2rem, 4.4vw, 2.75rem);   /* name size: min, scales with screen, max */
  letter-spacing: -0.015em;
  line-height: 1.04;
  margin-bottom: 1rem;
}
.hero h1 span { display: block; }
/* Keeps "Arellano Martorellet" on one line on laptops and desktops */
@media (min-width: 900px) {
  .hero h1 span { white-space: nowrap; }
}

.position {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1.6rem;
}
.position strong { color: var(--ink); font-weight: 500; }

.bio p { max-width: var(--text); }

/* Contact icons under the bio */
.icon-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}
.icon-links a {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  color: var(--ink);
  font-size: 1.3rem;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}
.icon-links a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.icon-links li:first-child a { margin-left: -0.55rem; } /* lines the first icon up with the text above */

/* The cut-out photo "stands" on the line above the research themes.
   The soft circle and small dot behind it are drawn here, not in the image. */
.figure {
  position: relative;
  margin: 0;
  height: 23.85rem;           /* photo height (10% smaller than the original 26.5rem) */
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.figure::before {
  content: "";
  position: absolute;
  border-radius: 50%;
  z-index: 0;
}
.figure::before {            /* soft circle */
  width: 15.75rem;
  height: 15.75rem;
  background: var(--accent-soft);
  left: 50%;
  top: 3.4rem;
  transform: translateX(-50%);
}
.ball {                      /* small gold dot: secretly a link to the tennis game */
  position: absolute;
  z-index: 2;
  width: 2.85rem;               /* 5% smaller than the original 3rem */
  height: 2.85rem;
  border-radius: 50%;
  background-color: var(--amber-soft);
  /* the two white seam lines of a tennis ball */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' opacity='0.9'%3E%3Cpath d='M15 4 C30 18 30 46 15 60'/%3E%3Cpath d='M49 4 C34 18 34 46 49 60'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  right: 0;
  top: 2.5rem;
  transition: transform 0.2s ease;
  animation: ball-float 4s ease-in-out infinite;   /* slow, gentle bob */
}
.ball:hover { transform: scale(1.12) rotate(20deg); }
@keyframes ball-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -8px; }
}
/* No floating for visitors who have asked their device to reduce motion */
@media (prefers-reduced-motion: reduce) {
  .ball { animation: none; }
}
.figure img {
  position: relative;
  z-index: 1;
  height: 100%;
  width: auto;
  display: block;
}

/* Research themes: three columns, each with its own color dot */
.dot {
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--dot, var(--accent));
  display: inline-block;
}
.themes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--rule);
}
.hero { border-bottom: 1px solid var(--rule); }   /* the line the photo stands on */
.themes-title {                /* "Questions that drive my work" */
  font-size: 1.5rem;
  margin: 2.5rem 0 0.25rem;
}
.theme { padding: 1.6rem 1.6rem 1.6rem 0; }
.theme + .theme {
  padding-left: 1.6rem;
  border-left: 1px solid var(--rule);
}
.theme h2 {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}
.theme p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.theme .questions {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.theme .questions li + li { margin-top: 0.5rem; }

/* "See my research" button under the three themes */
.research-link { margin: 2rem 0 0; }
.button-link {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.button-link:hover {
  background: var(--accent);
  color: var(--paper);
}

/* Current work list */
.current { margin-top: 2.75rem; }
.current > h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}
.work {
  list-style: none;
  margin: 0;
  padding: 0;
}
.work li {
  display: flex;
  gap: 0.9rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
}
.work .dot {
  width: 0.62rem;
  height: 0.62rem;
  margin-top: 0.55rem;
}
.work .dots {                /* papers that belong to two themes */
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.work .dots .dot { margin-top: 0; }
.work h3 {
  font-size: 1.18rem;
  line-height: 1.3;
}
.work .meta {
  font-size: 0.88rem;
  color: var(--muted);
}
.see-all {
  margin: 1rem 0 0;
  font-size: 0.95rem;
}

/* ---------- Inner pages (Research, CV) ---------- */

.page-title {
  font-size: clamp(2rem, 5vw, 2.6rem);
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}
.page-lede {
  color: var(--muted);
  margin-bottom: 0;
  max-width: var(--text);
}

.section { margin-top: 3.25rem; }
.section > h2 {
  font-size: 1.55rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.5rem;
}

/* A publication or working paper */
.entry { margin-bottom: 1.9rem; }
.entry:last-child { margin-bottom: 0; }
.entry h3 {
  font-size: 1.28rem;
  margin-bottom: 0.3rem;
}
.entry .authors { margin: 0 0 0.15rem; }
.entry .authors .me { font-weight: 600; }
.entry .venue {
  color: var(--muted);
  margin: 0 0 0.4rem;
}
.entry .summary {
  margin: 0.3rem 0 0.4rem;
  max-width: var(--text);
}
.status {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1rem 0.55rem;
  border-radius: 4px;
  margin-bottom: 0.35rem;
}
.entry-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.93rem;
}

/* Theme key and theme dots on the Research and CV pages */
.theme-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.theme-key li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.entry { padding-left: 1.5rem; }
.entry h3 { position: relative; }
.entry h3 .dot {
  position: absolute;
  left: -1.5rem;
  top: 0.42em;
  width: 0.65rem;
  height: 0.65rem;
}
.entry h3 .dot + .dot { top: calc(0.42em + 0.95rem); }  /* second theme dot, stacked below */
.dated .when .dot {
  width: 0.6rem;
  height: 0.6rem;
  margin-left: 0.55rem;
  vertical-align: 0.05em;
}

/* A publication shown with a small cover image on the right */
.entry.with-cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem;
  column-gap: 2rem;
  align-items: start;
}
.entry-body { min-width: 0; }
.cover { display: block; margin-top: 0.3rem; }
.cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(20, 30, 45, 0.18), 0 6px 16px rgba(20, 30, 45, 0.12);
  transition: transform 0.2s ease;
}
.cover:hover img { transform: translateY(-2px); }
/* faint outline so the dark cover stays visible on the dark background */
:root[data-theme="dark"] .cover img { outline: 1px solid rgba(255, 255, 255, 0.14); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cover img { outline: 1px solid rgba(255, 255, 255, 0.14); }
}
@media (max-width: 640px) {
  .entry.with-cover { grid-template-columns: 1fr; }
  .cover { width: 5.5rem; margin-top: 1rem; }
}

/* Simple dated list used for talks, education, teaching, awards */
.dated {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dated li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--rule);
}
.dated li:last-child { border-bottom: 0; }
.dated .when {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dated .what strong { font-weight: 600; }
.dated .detail {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
}

.cv-download {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
}
.cv-download:hover { background: var(--accent-soft); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .figure {                  /* photo moves above the name */
    order: -1;
    height: 15.3rem;
    justify-content: flex-start;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 1.75rem;
  }
  .figure::before { width: 10.8rem; height: 10.8rem; top: 2.25rem; left: 5.4rem; }
  .ball { width: 1.9rem; height: 1.9rem; top: 1.3rem; right: auto; left: 10.4rem; }
  .hero-text { padding-bottom: 2.25rem; }
  .themes { grid-template-columns: 1fr; }
  .theme,
  .theme + .theme {
    padding: 1.25rem 0;
    border-left: 0;
  }
  .theme + .theme { border-top: 1px solid var(--rule); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 1.25rem; }
  main { padding: 2rem 0 3rem; }
  .site-nav ul { gap: 1.15rem; }
  .dated li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
}

@media print {
  .site-header, .site-footer, .cv-download { display: none; }
  body { background: #fff; color: #000; }
}
