/* Atte Toivanen — portfolio, 90-luvun työpöytä */

@font-face {
  font-family: "Pixelify Sans";
  src: url("fonts/pixelify-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin-opsz-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "VT323";
  src: url("fonts/vt323-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* Työpöytä ja ikkunoiden harmaa */
  --desktop: #008080;
  --face: #c0c0c0;
  --hilite: #ffffff;
  --light: #dfdfdf;
  --shadow: #808080;
  --dark: #000000;
  --ink: #000000;
  --ink-soft: #3a3a3a;
  --paper: #ffffff;
  --tip: #ffffe1;
  --select: #000080;
  --title-a: #000080;
  --title-b: #1084d0;
  --title-off-a: #6b6b6b;
  --title-off-b: #9c9c9c;
  --dos-bg: #000000;
  --dos-ink: #c0c0c0;

  --font-ui: "Pixelify Sans", Tahoma, Verdana, "Segoe UI", sans-serif;
  --font-doc: "Source Serif 4", "Times New Roman", Georgia, serif;
  --font-dos: "VT323", "Lucida Console", "Courier New", monospace;

  /* Kohokuviot: ulospäin ja sisäänpäin */
  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--light), inset -2px -2px var(--shadow), inset 2px 2px var(--hilite);
  --button: inset -1px -1px var(--dark), inset 1px 1px var(--hilite), inset -2px -2px var(--shadow), inset 2px 2px var(--light);
  --pressed: inset -1px -1px var(--hilite), inset 1px 1px var(--dark), inset -2px -2px var(--light), inset 2px 2px var(--shadow);
  --sunken: inset -1px -1px var(--hilite), inset 1px 1px var(--shadow), inset -2px -2px var(--light), inset 2px 2px var(--dark);
  --thin-sunken: inset -1px -1px var(--hilite), inset 1px 1px var(--shadow);

  --measure: 40rem;
  --taskbar-h: 2.5rem;
  color-scheme: light;
}

/* Kieliversiot: vain aktiivisen kielen tekstit näkyvät */
html[data-lang="fi"] [lang="en"],
html[data-lang="en"] [lang="fi"]:not(html):not(.thesis-title) {
  display: none !important;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--desktop);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.4;
  padding-bottom: calc(var(--taskbar-h) + env(safe-area-inset-bottom, 0px));
}

p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; font-weight: 700; }

a { color: var(--select); text-underline-offset: 0.15em; }

/* Windows-tyylinen pisteviivakohdistus, vähän paksumpana */
:focus-visible {
  outline: 2px dotted var(--ink);
  outline-offset: 2px;
}

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 16px;
  height: 16px;
  flex: none;
  image-rendering: pixelated;
}
.ico-lg { width: 32px; height: 32px; }
.ico-xl { width: 48px; height: 48px; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 50;
  background: var(--face);
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  box-shadow: var(--button);
}
.skip:focus { top: 1rem; }

/* ---------- Työpöytä ---------- */

.desktop {
  max-width: 66rem;
  margin: 0 auto;
  padding-block: clamp(1rem, 4vw, 2.5rem) 1.5rem;
  padding-inline: max(1rem, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 3vw, 2rem);
}

/* ---------- Ikkuna ---------- */

.window {
  background: var(--face);
  box-shadow: var(--raised);
  padding: 3px;
  width: 100%;
  scroll-margin-top: 1rem;
}
.window[hidden] { display: none; }

.titlebar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
  padding: 2px 3px 2px 4px;
  background: linear-gradient(90deg, var(--title-off-a), var(--title-off-b));
  color: var(--hilite);
}
.window.is-active .titlebar {
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
}
.titlebar .title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.controls {
  display: flex;
  flex: none;
  align-self: flex-start;
  margin-top: 2px;
}
.ctl {
  width: 1.375rem;
  height: 1.25rem;
  padding: 0;
  border: 0;
  background: var(--face);
  box-shadow: var(--button);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ctl svg { width: 9px; height: 9px; fill: currentColor; }
.ctl:active { box-shadow: var(--pressed); }
.ctl:active svg { transform: translate(1px, 1px); }
.ctl:focus-visible { outline-offset: -5px; outline-width: 1px; }
.ctl-close { margin-left: 2px; }

.window-body { margin: 0.5rem; }
.window.is-min .window-body { display: none; }

/* Porrastetut ikkunat leveällä näytöllä */
@media (min-width: 960px) {
  .win-welcome    { max-width: 50rem; }
  .win-dos        { max-width: 46rem; margin-left: 7rem; }
  .win-projects   { max-width: 60rem; margin-left: 2.5rem; }
  .win-thesis     { max-width: 44rem; margin-left: 11rem; }
  .win-skills     { max-width: 42rem; margin-left: 4.5rem; }
  .win-ai         { max-width: 50rem; margin-left: 12rem; }
  .win-experience { max-width: 50rem; margin-left: 7rem; }
  .win-contact    { max-width: 36rem; margin-left: 15rem; }
}
.window.is-max { max-width: none; margin-left: 0; }

/* ---------- Painikkeet ja kentät ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-width: 6.5rem;
  min-height: 2rem;
  padding: 0.25rem 1rem;
  border: 0;
  background: var(--face);
  box-shadow: var(--button);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.btn:active,
.btn[aria-expanded="true"] { box-shadow: var(--pressed); }
.btn:active > *,
.btn[aria-expanded="true"] > * { transform: translate(1px, 1px); }
.btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: -5px; }
/* Oletuspainikkeen musta kehys */
.btn-default {
  box-shadow: inset 0 0 0 1px var(--dark), inset -2px -2px var(--dark), inset 2px 2px var(--hilite), inset -3px -3px var(--shadow), inset 3px 3px var(--light);
}
.btn-default:active { box-shadow: inset 0 0 0 1px var(--dark), inset 0 0 0 2px var(--shadow); }

.field {
  background: var(--paper);
  box-shadow: var(--sunken);
  padding: 0.25rem 0.5rem;
}

.pane {
  background: var(--paper);
  box-shadow: var(--sunken);
  padding: 2px;
}

.statusbar {
  display: flex;
  gap: 2px;
  margin-top: 0.375rem;
  font-size: 0.875rem;
}
.statusbar .field {
  background: transparent;
  box-shadow: var(--thin-sunken);
  padding: 0.125rem 0.5rem;
  white-space: nowrap;
}
.statusbar .field-grow { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tervetuloa ---------- */

.welcome {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.25rem 1.5rem;
  padding: clamp(0.5rem, 2vw, 1rem);
}
.welcome h1 {
  font-size: clamp(2.5rem, 9vw, 4.75rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
  color: var(--ink);
}
.lede {
  font-family: var(--font-doc);
  font-size: clamp(1.125rem, 2.2vw, 1.3rem);
  line-height: 1.5;
  max-width: var(--measure);
}
.tip {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  background: var(--tip);
  box-shadow: var(--sunken);
  padding: 0.875rem 1rem;
  max-width: var(--measure);
}
.tip-head { font-weight: 700; margin: 0 0 0.25rem; }
.looking {
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.5;
  margin: 0;
}
.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---------- Komentokehote (sivun signatuuri) ---------- */

.win-dos .window-body { margin: 2px; }
.term {
  background: var(--dos-bg);
  color: var(--dos-ink);
  box-shadow: var(--sunken);
  padding: 0.875rem 1rem 1rem;
  font-family: var(--font-dos);
  font-size: 1.375rem;
  line-height: 1.2;
}
.term p { margin: 0; max-width: 62ch; }
.term .prompt { color: var(--hilite); }
.term .prompt:not(:first-child) { margin-top: 0.8em; }
.term strong { color: var(--hilite); font-weight: 400; }

.hops {
  list-style: none;
  margin: 0.6em 0;
  padding: 0;
  counter-reset: hop;
}
.hop {
  counter-increment: hop;
  display: grid;
  grid-template-columns: 4ch 24ch 1fr;
}
.hop::before {
  content: counter(hop, decimal);
  text-align: right;
  padding-right: 2ch;
}
.hop-home .hop-name { color: var(--hilite); }

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.15em;
  background: var(--dos-ink);
  vertical-align: baseline;
  animation: blink 1.06s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Rivit ilmestyvät kerran kuin tracert kulkisi (app.js) */
.term.is-pending .term-line { visibility: hidden; }
.term.is-pending .term-line.is-shown { visibility: visible; }

/* ---------- Projektit ---------- */

.address {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
}
.address-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.375rem;
  white-space: nowrap;
  overflow: hidden;
}

.project {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 0.75rem 2rem;
  padding: 1.25rem clamp(0.75rem, 2.5vw, 1.5rem);
}
.project + .project { border-top: 1px dotted var(--shadow); }
.project-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.project h3 {
  font-size: 1.25rem;
  line-height: 1.15;
  margin-bottom: 0.25rem;
}
.meta {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.project-body {
  max-width: var(--measure);
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.tags {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  line-height: 1.2;
}
.tags li {
  background: var(--face);
  box-shadow: var(--thin-sunken);
  padding: 0.1875rem 0.4375rem;
}

/* ---------- Tutkielma ---------- */

.page-surround {
  background: var(--shadow);
  padding: clamp(0.75rem, 3vw, 1.75rem);
}
.page {
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--dark);
  padding: clamp(1.25rem, 4vw, 2.75rem) clamp(1.25rem, 5vw, 3.25rem);
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.65;
}
.page p { max-width: var(--measure); }
.page p:last-child { margin-bottom: 0; }
.thesis-title {
  font-size: clamp(1.35rem, 2.8vw, 1.75rem);
  font-weight: 650;
  line-height: 1.25;
}
.thesis-translation { font-style: italic; margin-top: -0.5em; }
html[data-lang="fi"] .thesis-translation { display: none; }

/* ---------- Osaaminen ---------- */

.skills {
  margin: 0;
  padding: clamp(0.5rem, 2vw, 1rem);
  display: grid;
  gap: 0.625rem;
}
.skills > div {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 0.25rem 1rem;
  align-items: center;
}
.skills dt { font-weight: 600; }
.skills dd {
  margin: 0;
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.45;
  padding: 0.3125rem 0.625rem;
}

/* ---------- Tekoäly: ohjattu toiminto ---------- */

.wizard {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: clamp(1rem, 3vw, 1.75rem);
  padding: clamp(0.5rem, 2vw, 1rem);
}
.wizard-art {
  position: relative;
  min-height: 14rem;
  background: linear-gradient(180deg, var(--desktop), var(--title-a));
  box-shadow: var(--sunken);
  display: grid;
  place-items: end center;
  padding-bottom: 1.5rem;
}
.wizard-wand {
  position: absolute;
  top: 1.25rem;
  right: 1rem;
}
.wizard-main {
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.6;
}
.wizard-main p { max-width: var(--measure); }
.wizard-intro {
  font-size: 1.1875rem;
  line-height: 1.55;
}
.wizard-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  margin: 1.25rem 0 0;
  font-family: var(--font-ui);
  font-size: 1rem;
}
.wizard-tools dt { font-weight: 700; }
.wizard-tools dd {
  margin: 0;
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  padding: 0.25rem 0.625rem;
}

/* ---------- Koulutus ja kokemus ---------- */

.pane-table { padding: 2px; overflow-x: auto; }
.details {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}
.details th {
  text-align: left;
  font-weight: 400;
  background: var(--face);
  box-shadow: var(--button);
  padding: 0.25rem 0.625rem;
  position: sticky;
  top: 0;
}
.details td {
  padding: 0.4375rem 0.625rem;
  vertical-align: top;
}
.details td:last-child {
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.4;
}
.details h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
.details tbody tr:hover td { background: var(--select); color: var(--hilite); }

/* ---------- Yhteystiedot ---------- */

.dialog { padding: clamp(0.5rem, 2vw, 1rem); }
.dialog-message {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  font-family: var(--font-doc);
  font-size: 1.125rem;
  line-height: 1.5;
}
.dialog-message p { margin: 0.25rem 0 0; max-width: 30rem; }
.dialog-buttons {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.foot {
  color: var(--hilite);
  font-size: 0.9375rem;
  text-align: right;
}
.foot p { margin: 0; }

/* ---------- Tehtäväpalkki ---------- */

.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--taskbar-h);
  padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
  background: var(--face);
  box-shadow: inset 0 1px var(--light), inset 0 2px var(--hilite);
}
.start {
  min-width: 0;
  min-height: 1.875rem;
  padding: 0.125rem 0.5rem 0.125rem 0.375rem;
  font-weight: 700;
  flex: none;
}
.taskbar-sep {
  width: 2px;
  align-self: stretch;
  margin: 2px 2px;
  box-shadow: inset 1px 0 var(--shadow), inset -1px 0 var(--hilite);
  flex: none;
}
.tasks {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 3px;
  overflow: hidden;
}
.task {
  flex: 0 1 10rem;
  min-width: 2.25rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.875rem;
  padding: 0 0.5rem;
  background: var(--face);
  box-shadow: var(--button);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
}
.task span { overflow: hidden; text-overflow: ellipsis; }
.task[hidden] { display: none; }
.task.is-active {
  box-shadow: var(--pressed);
  background-color: var(--hilite);
  background-image: conic-gradient(var(--face) 25%, var(--hilite) 0 50%, var(--face) 0 75%, var(--hilite) 0);
  background-size: 2px 2px;
  font-weight: 700;
}
.tray {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.875rem;
  padding: 0 0.625rem 0 0.375rem;
  box-shadow: var(--thin-sunken);
  font-size: 0.9375rem;
}
.tray-lang {
  font: inherit;
  font-weight: 700;
  color: var(--hilite);
  background: var(--select);
  border: 0;
  padding: 0 0.25rem;
  line-height: 1.25;
  cursor: pointer;
}
.clock { white-space: nowrap; }

/* ---------- Käynnistä-valikko ---------- */

.startmenu {
  position: fixed;
  left: max(2px, env(safe-area-inset-left, 0px));
  bottom: calc(var(--taskbar-h) + env(safe-area-inset-bottom, 0px) - 2px);
  z-index: 45;
  display: flex;
  background: var(--face);
  box-shadow: var(--raised);
  padding: 3px;
  max-height: calc(100vh - var(--taskbar-h) - 1rem);
  overflow-y: auto;
}
.startmenu[hidden] { display: none; }
.startmenu-banner {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: linear-gradient(0deg, var(--title-a), var(--title-b));
  color: var(--face);
  font-weight: 700;
  font-size: 1.375rem;
  letter-spacing: 0.02em;
  padding: 0.5rem 0.25rem;
  text-align: right;
}
.startmenu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 15rem;
}
.startmenu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3125rem 1.5rem 0.3125rem 0.5rem;
  color: var(--ink);
  text-decoration: none;
}
.startmenu a:hover,
.startmenu a:focus-visible {
  background: var(--select);
  color: var(--hilite);
  outline: 0;
}
.startmenu .sep {
  height: 2px;
  margin: 3px 2px;
  box-shadow: inset 0 1px var(--shadow), inset 0 -1px var(--hilite);
}

/* ---------- Kapeat näytöt ---------- */

@media (max-width: 760px) {
  .welcome { grid-template-columns: 1fr; }
  .welcome-actions { flex-direction: row; flex-wrap: wrap; }
  .project { grid-template-columns: 1fr; gap: 0.75rem; }
  .skills > div { grid-template-columns: 1fr; }
  .wizard { grid-template-columns: 1fr; }
  .wizard-art { min-height: 4.5rem; place-items: center start; padding: 0 1rem; }
  .wizard-art .ico-xl { width: 32px; height: 32px; }
  .wizard-wand { top: auto; right: 1rem; }
  .tasks { display: none; }
  .taskbar-sep { display: none; }
  .tray { margin-left: auto; }
}

@media (max-width: 560px) {
  .term { font-size: 1.25rem; padding: 0.75rem; }
  .hop { grid-template-columns: 3ch 1fr; }
  .hop::before { padding-right: 1ch; }
  .hop-detail { grid-column: 2; }
  .titlebar .title { font-size: 1rem; }
  .welcome-actions .btn { flex: 1 1 8rem; }
  .dialog-buttons { justify-content: stretch; }
  .dialog-buttons li { flex: 1 1 100%; }
  .dialog-buttons .btn { width: 100%; }
  .dialog-message .ico-xl { width: 32px; height: 32px; }
  .details th:last-child { display: none; }
  .details tr { display: block; padding: 0.375rem 0; }
  .details tr + tr { border-top: 1px dotted var(--shadow); }
  .details td { display: block; padding: 0.125rem 0.625rem; }
  .details td:last-child { padding-left: calc(0.625rem + 16px + 0.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
}

@media print {
  .taskbar, .startmenu, .skip, .controls, .win-dos, .address, .statusbar { display: none !important; }
  body { background: #fff; padding: 0; }
  .window { box-shadow: none; border: 1px solid #000; margin-left: 0 !important; max-width: none !important; }
  .window[hidden] { display: block !important; }
  .window.is-min .window-body { display: block; }
}
