@media all and (orientation:portrait) {

  :root {
    --bg-primary: #faf8f3;
    --bg-secondary: #f5f3ed;
    --text-primary: #2a2520;
    --text-secondary: #6b6459;
    --accent-primary: #8b7d5b;
    --accent-light: #a89968;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 12px rgba(42, 37, 32, 0.08);
    --card-shadow-hover: 0 4px 20px rgba(42, 37, 32, 0.12);
  }

  * {
    box-sizing: border-box;
  }

  /* Now that the viewport meta tag reports the real device width, any
     element with a hardcoded pixel width wider than the screen (e.g. the
     504px LinkedIn embeds in #news, the 400px image in #contacts) would
     force horizontal scrolling. Cap them to the available width. */
  img {
    max-width: 100%;
    height: auto;
  }

  iframe {
    max-width: 100%;
  }

  body {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 400;
    overflow-x: hidden;
  }

  #undercons {
    position: fixed;
    top: auto;
    margin: 0;
    z-index: 100;
    bottom: 0px;
    right: -50px;
    bottom: -50px;
  }

  #cv div span {
    display: none;
  }
  
  #cv ul li span {
    display: none;
  }

  .content {
    visibility: visible;
    position: relative;
    margin: 0;
    padding: 0;
  }

  h1 {
    padding-top: 0;
    font-size: 20px;
    margin: 1.5rem 0 0.75rem 0;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
  }

  h2 {
    font-size: 18px;
    margin: 1.5rem 0 1rem 0;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
  }

  h3 {
    font-size: 16px;
    margin: 1rem 0 0.75rem 0;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
  }

  p {
    margin: 0.75rem 0;
    line-height: 1.85;
    color: var(--text-secondary);
    font-weight: 400;
  }

  .firstslide {
    padding: 100px 24px 80px 24px;
    text-align: center;
    margin-bottom: 40px;
  }

  .firstslide h1 {
    font-size: 2.5rem;
    margin: 0.5rem 0 1rem 0;
  }

  .firstslide p {
    font-size: 1.15rem;
    margin: 1rem 0;
    line-height: 1.9;
    font-weight: 400;
  }


  .firstslide > div {
    margin-top: 32px;
  }

  .cvrsection {
    border-radius: 12px;
    margin: 20px 0;
    padding: 20px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--accent-primary);
    transition: all 0.3s ease;
  }

  .cvrsection:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
  }

  .cvrsection h1 {
    font-size: 1.75rem;
    margin-top: 0;
  }

  #home {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 93px);      /* occupy the full screen */
  margin: 0;
  padding: 0 24px;
  padding-top: 160px;
  padding-bottom: 60px;
  line-height: 1;

  display: flex;
  flex-direction: column;
  justify-content: center; /* vertically center content, fallback for older browsers */
  justify-content: safe center; /* ...but never let overflowing content bleed above the top of the screen and hide behind the fixed nav bar */
  align-items: center;     /* horizontally center content */
  text-align: center;
  }

  #home h1 {
      font-size: 2.4rem;
    }

  #home p {
    font-size: 1.2rem;
  }


  /* Desktop-only background overlay (see base.css) — switched off on mobile */
  #home::before {
    display: none;
  }

  main section {
    margin-bottom: 20px;
  }

  header {
    visibility: hidden;
  }

  section {
    padding-top: 20px;
    padding-left: 12px;
    padding-bottom: 60px;
    padding-right: 12px;
    width: auto;
  }

  /* Touch-friendly button sizing */
  a[style*="border-radius"],
  .btn {
    min-height: 48px;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Primary action button */
  a[href*="matteolionello_cv.pdf"] {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 16px rgba(139, 125, 91, 0.25);
    border: none;
    margin: 8px 8px;
  }

  a[href*="matteolionello_cv.pdf"]:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(139, 125, 91, 0.15);
  }

    a[href*="linkedin.com"]:active,
  a[href*="github.com"]:active {
    background: rgba(139, 125, 91, 0.08);
    transform: scale(0.98);
  }

  /* Social icons footer */
  .icons {
    float: right;
    margin-top: 8px;
    margin-right: 16px;
    transition: all 0.3s ease;
  }

  .icons img {
    width: 15%;
    opacity: 0.8;
    box-shadow: 0 2px 6px rgba(42, 37, 32, 0.1);
    transition: all 0.3s ease;
    border-radius: 4px;
  }

  .icons img:active {
    opacity: 1;
    transform: scale(0.95);
    box-shadow: 0 4px 12px rgba(42, 37, 32, 0.15);
  }

  footer div {
    display: none;
  }

  .showmeinmobile {
    display: block;
  }

  .showmeinmobile h1 {
    margin-top: 0;
    padding-top: 0;
  }

  .cvrsection hr {
    visibility: hidden;
    margin: 0;
    padding: 0;
    height: 0;
  }

  /* List improvements */
  #projects h3 {
    margin-left: 0;
    padding-left: 0;
    list-style-position: inside;
  }

  #projects p {
    padding-left: 0;
    margin-left: 0.5rem;
  }

  #projects .cvrsection p {
    display: none;
  }

  #publications br + br {
    display: none;

  }

  #publications .yearpub {
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 4px;
    padding-top: 4px;
    display: span;
  }

  #sum div {
    display: block !important;
    margin: 0 auto !important;
    padding: 0 5% !important;
    margin: 0 !important;
    width: 100% !important;
  }

  #fotoid {
    text-align: center;
    width: 40% !important;
  }

  #fotoid img{
    width: 30% !important;
  }

  #contacts span a img {
    width: 15%;
    padding: 24px;
    opacity: 0.85;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }

  #contacts span a:active img {
    opacity: 1;
    transform: scale(0.95);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
  }

  /* Content spacing */
  .content section {
    padding-bottom: 40px;
  }

  .content section:last-child {
    padding-bottom: 80px;
  }

  #downloadidwrapperdiv {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
  }
}
